Skip to content
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

App config/settings REST/OCS API #10961

Closed
weeman1337 opened this issue Sep 2, 2018 · 6 comments
Closed

App config/settings REST/OCS API #10961

weeman1337 opened this issue Sep 2, 2018 · 6 comments

Comments

@weeman1337
Copy link
Member

Story
As an app developer I want to have an API for reading and storing app config/settings,
so I save time that I can spend on implementing amazing features in my app ;)

Background
Some apps use app config/setting values. Currently they're all implementing an own "store settings handler". It would be handy to have an API that can be used for this.

This is about making the app part of IConfig available as an API.

Outline

  • Endpoint for reading all, one or more app config values
  • Endpoint for storing one or more app config values
  • Endpoint for deleting app config values
  • Update of the NC app development documentation settings section
@nextcloud-bot
Copy link
Member

GitMate.io thinks possibly related issues are #3617 (Setting Favorite API), #9856 (Introducing user config provisionning api), #4159 (Shared API ), #676 (Search API), and #3923 (Preview API).

@MorrisJobke
Copy link
Member

This is about making the app part of IConfig available as an API.

IConfig is already public API and can be used for this. ;)

Inject it into the constructor:

IDBConnection $db, IConfig $config,

Set it:

$this->config->setAppValue($this->appName, 'generateBirthdayCalendar', 'yes');

🙌

@weeman1337
Copy link
Member Author

@MorrisJobke maybe the title is a bit misleading. It's about a REST API.

@MorrisJobke MorrisJobke reopened this Oct 1, 2018
@MorrisJobke MorrisJobke changed the title App config/settings API App config/settings REST/OCS API Oct 1, 2018
@MorrisJobke
Copy link
Member

@rullzer @nickvergessen @blizzz Isn't there already an OCS API endpoint for this?

@rullzer
Copy link
Member

rullzer commented Oct 1, 2018

I have been thinking about this as well.

For me it would make sense to have a basic controller. That exposes the appconfig for a specific app

The dev can then set some types for the config values they have
like setType('foo', 'int') etc.

And then it can also write some functions like

function fromFoo(int $var): string
funtion toFoo(string $var): int
`function validateFoo(string $var): bool

etc. That way there is an easy framework to validate appconfig vars of an app. And the dev only has to worry about the part specific for their app and variables. The rest is all magically handled by the controller.

@nickvergessen
Copy link
Member

// Config
['name' => 'AppConfig#getApps', 'url' => '/api/v1/config/apps', 'verb' => 'GET'],
['name' => 'AppConfig#getKeys', 'url' => '/api/v1/config/apps/{app}', 'verb' => 'GET'],
['name' => 'AppConfig#getValue', 'url' => '/api/v1/config/apps/{app}/{key}', 'verb' => 'GET'],
['name' => 'AppConfig#setValue', 'url' => '/api/v1/config/apps/{app}/{key}', 'verb' => 'POST'],
['name' => 'AppConfig#deleteKey', 'url' => '/api/v1/config/apps/{app}/{key}', 'verb' => 'DELETE'],

So try /ocs/v2.php/apps/provisioning_api/api/v1/config/apps*

Does exactly that with the IConfig::*AppValue methods:
https://github.com/nextcloud/server/blob/47cc5e5895ded011a42cfc02957017aa61a42979/apps/provisioning_api/lib/Controller/AppConfigController.php

The only thing it does not allow is setting the install/enable/type configs, because they should not be set manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants