-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
provisioning_api: Add OpenAPI spec #39223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
provisioning_api: Add OpenAPI spec
Signed-off-by: jld3103 <[email protected]>
- Loading branch information
commit 38db3873a263974645ece09ed5677324f603f08c
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.