mirror of
https://github.com/YunoHost/doc.git
synced 2024-09-03 20:06:26 +02:00
Drop the 'extend' section ... these are just pointers to the app packaging doc ... move the theming doc to 'tutorials'
This commit is contained in:
parent
147bd3848d
commit
36d3874f87
6 changed files with 0 additions and 145 deletions
|
@ -1,5 +0,0 @@
|
|||
---
|
||||
title: Hooks
|
||||
template: docs
|
||||
redirect: '/packaging_apps_hooks'
|
||||
---
|
|
@ -1,63 +0,0 @@
|
|||
---
|
||||
title: Administration depuis l'API ou une application externe
|
||||
template: docs
|
||||
taxonomy:
|
||||
category: docs
|
||||
routes:
|
||||
default: '/admin_api'
|
||||
---
|
||||
|
||||
Toutes les actions exécutables en ligne de commande le sont également via une API. L’API est accessible à l’adresse <https://votre.serveur/yunohost/api>.
|
||||
Pour le moment, il n'existe pas de documentation des différentes routes... mais vous pouvez trouver l'actionmap [ici](https://github.com/YunoHost/yunohost/blob/dev/share/actionsmap.yml) (en particulier les clefs `api`)
|
||||
|
||||
## Avec cURL
|
||||
|
||||
Il faut d’abord récupérer un cookie de connexion pour ensuite réaliser les actions. Voici un exemple avec cURL :
|
||||
|
||||
```bash
|
||||
# Login (avec mot de passe admin)
|
||||
curl -k -H "X-Requested-With: customscript" \
|
||||
-d "password=supersecretpassword" \
|
||||
-dump-header headers \
|
||||
https://your.server/yunohost/api/login
|
||||
|
||||
# Exemple de GET
|
||||
curl -k -i -H "Accept: application/json" \
|
||||
-H "Content-Type: application/json" \
|
||||
-L -b headers -X GET https://your.server/yunohost/api/ROUTE \
|
||||
| grep } | python -mjson.tool
|
||||
```
|
||||
|
||||
## Avec une classe PHP
|
||||
|
||||
Pour simplifier l’administration à distance d’une instance YunoHost dans le cadre d’un projet CHATONS/Librehosters, des classes API ont été développées par des utilisateurs.
|
||||
|
||||
Par exemple, cette [classe PHP](https://github.com/scith/yunohost-api-php) vous permettra d’administrer votre instance YunoHost depuis une application PHP (site Web, outil de gestion de capacité...).
|
||||
|
||||
Voici un exemple de code PHP permettant d’ajouter un utilisateur dans votre instance YunoHost :
|
||||
|
||||
```php
|
||||
require("ynh_api.class.php");
|
||||
$ynh = new YNH_API("adresse IP du serveur YunoHost ou nom d’hôte", "mot de passe administrateur");
|
||||
|
||||
if ($ynh->login()) {
|
||||
$domains = $ynh->get("/domains");
|
||||
$first_domain = $domains['domains'][0];
|
||||
|
||||
$arguments = array(
|
||||
'username' => 'test',
|
||||
'password' => 'yunohost',
|
||||
'firstname' => 'Prénom',
|
||||
'lastname' => 'Nom',
|
||||
'mail' => 'test@'.$first_domain,
|
||||
'mailbox_quota' => '500M'
|
||||
);
|
||||
|
||||
$user_add = $ynh->post("/users", $arguments);
|
||||
print_r($user_add);
|
||||
|
||||
} else {
|
||||
print("Login to YunoHost failed.\n");
|
||||
exit;
|
||||
}
|
||||
```
|
|
@ -1,67 +0,0 @@
|
|||
---
|
||||
title: Administration from the API or an external application
|
||||
template: docs
|
||||
taxonomy:
|
||||
category: docs
|
||||
routes:
|
||||
default: '/admin_api'
|
||||
---
|
||||
|
||||
All command line actions can also be ran from the web API. The API is available at <https://your.server/yunohost/api>.
|
||||
|
||||
## Test with curl
|
||||
|
||||
You must first retrieve a login cookie thanks to the /login route to perform the other actions.
|
||||
|
||||
```bash
|
||||
# Login (with admin password)
|
||||
curl -k -H "X-Requested-With: customscript" \
|
||||
-d "credentials=supersecretpassword" \
|
||||
-dump-header headers \
|
||||
https://your.server/yunohost/api/login
|
||||
|
||||
# GET example
|
||||
curl -k -i -H "Accept: application/json" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H 'Cookie: yunohost.admin="XXXXXXXX"' \
|
||||
-L -b headers -X GET https://your.server/yunohost/api/ROUTE \
|
||||
| grep } | python -mjson.tool
|
||||
```
|
||||
|
||||
## Test with our swagger doc
|
||||
|
||||
1. Login on the [Webadmin of `demo.yunohost.org`](https://demo.yunohost.org/yunohost/admin/)
|
||||
2. Use the `Try it out` button on the API endpoint you want to test
|
||||
|
||||
<div id="swagger-ui"></div>
|
||||
<style>
|
||||
#swagger-ui .topbar {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
<link rel="stylesheet" type="text/css" href="/user/themes/YunoHost-docs/css/swagger-ui.css" />
|
||||
<script src="/user/themes/YunoHost-docs/js/swagger-ui-bundle.js" charset="UTF-8"> </script>
|
||||
<script src="/user/themes/YunoHost-docs/js/swagger-ui-standalone-preset.js" charset="UTF-8"> </script>
|
||||
<script src="/user/themes/YunoHost-docs/js/openapi.js" type="text/javascript" language="javascript"></script>
|
||||
<script>
|
||||
window.onload = function() {
|
||||
//<editor-fold desc="Changeable Configuration Block">
|
||||
// the following lines will be replaced by docker/configurator, when it runs in a docker-container
|
||||
window.ui = SwaggerUIBundle({
|
||||
spec: openapiJSON,
|
||||
dom_id: '#swagger-ui',
|
||||
deepLinking: true,
|
||||
displayOperationId: true,
|
||||
validatorUrl: null,
|
||||
presets: [
|
||||
SwaggerUIBundle.presets.apis,
|
||||
SwaggerUIStandalonePreset
|
||||
],
|
||||
withCredentials: true,
|
||||
layout: "StandaloneLayout"
|
||||
});
|
||||
|
||||
//</editor-fold>
|
||||
};
|
||||
|
||||
</script>
|
|
@ -1,10 +0,0 @@
|
|||
---
|
||||
title: Understand and extend YunoHost
|
||||
template: docs
|
||||
taxonomy:
|
||||
category: docs
|
||||
routes:
|
||||
default: '/extend'
|
||||
---
|
||||
|
||||
!! This section is to be written
|
Loading…
Add table
Reference in a new issue