Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

Plugins directory API: Difference between revisions

From MoodleDocs
(Add information about the API and first function)
 
m (Protected "Plugins directory API": Developer Docs Migration ([Edit=Allow only administrators] (indefinite)))
 
(10 intermediate revisions by 3 users not shown)
Line 1: Line 1:
The Plugins directory at http://moodle.org/plugins exposes some of its features via web services layer, allowing the community to develop custom tools and integrations with other services such as GitHub Actions or Travis CI.
{{Template:Migrated|newDocId=/general/community/plugincontribution/pluginsdirectory/api}}
 
== Plugins maintenance service ==
 
The Plugins maintenance service (<tt>plugins_maintenance</tt>) provides functions for the plugins maintainers. The service is declared as:
 
<code php>
'Plugins maintenance' => [
    'functions' => [
        'local_plugins_get_maintained_plugins',
        'local_plugins_add_version',
    ],
    'shortname' => 'plugins_maintenance',
    'requiredcapability' => 'local/plugins:editownplugins',
    'enabled' => true,
    'restrictedusers' => 0,
    'downloadfiles' => true,
    'uploadfiles' => true,
],
</code>
 
=== Getting the list of maintained plugins ===
 
The first external function <tt>local_plugins_get_maintained_plugins</tt> allows to read the list of all plugins and their recent versions the caller is maintainer of. It does not expect any parameters and its return structure is described as follows:
 
<code php>
return new external_multiple_structure(
    new external_single_structure([
        'id' => new external_value(PARAM_INT, 'Internal plugin identifier'),
        'name' => new external_value(PARAM_TEXT, 'Name of the plugin'),
        'shortdescription' => new external_value(PARAM_TEXT, 'Short description'),
        'description' => new external_value(PARAM_RAW, 'Description'),
        'descriptionformat' => new external_format_value('description'),
        'frankenstyle' => new external_value(PARAM_PLUGIN, 'Full component frankenstyle name'),
        'type' => new external_value(PARAM_ALPHANUMEXT, 'Plugin type'),
        'websiteurl' => new external_value(PARAM_URL, 'Website URL'),
        'sourcecontrolurl' => new external_value(PARAM_URL, 'Source control URL'),
        'bugtrackerurl' => new external_value(PARAM_URL, 'Bug tracker URL'),
        'discussionurl' => new external_value(PARAM_URL, 'Discussion URL'),
        'timecreated' => new external_value(PARAM_INT, 'Timestamp of plugin submission'),
        'approved' => new external_value(PARAM_INT, 'Approval status'),
        'visible' => new external_value(PARAM_BOOL, 'Visibility status'),
        'aggdownloads' => new external_value(PARAM_INT, 'Stats aggregataion - downloads'),
        'aggfavs' => new external_value(PARAM_INT, 'Stats aggregataion - favourites'),
        'aggsites' => new external_value(PARAM_INT, 'Stats aggregataion - sites'),
        'statusamos' => new external_value(PARAM_INT, 'AMOS registration status'),
        'viewurl' => new external_value(PARAM_URL, 'View URL'),
        'currentversions' => new external_multiple_structure(
            new external_single_structure([
                'id' => new external_value(PARAM_INT, 'Internal version identifier'),
                'version' => new external_value(PARAM_INT, 'Version number'),
                'releasename' => new external_value(PARAM_TEXT, 'Release name'),
                'releasenotes' => new external_value(PARAM_RAW, 'Release notes'),
                'releasenotesformat' => new external_format_value('releasenotes'),
                'maturity' => new external_value(PARAM_INT, 'Maturity code'),
                'changelogurl' => new external_value(PARAM_URL, 'Change log URL'),
                'altdownloadurl' => new external_value(PARAM_URL, 'Alternative download URL'),
                'md5sum' => new external_value(PARAM_TEXT, 'MD5 hash of the ZIP content'),
                'vcssystem' => new external_value(PARAM_ALPHA, 'Version control system'),
                'vcssystemother' => new external_value(PARAM_TEXT, 'Name of the other version control system'),
                'vcsrepositoryurl' => new external_value(PARAM_URL, 'Version control system URL'),
                'vcsbranch' => new external_value(PARAM_TEXT, 'Name of the branch with this version'),
                'vcstag'  => new external_value(PARAM_TEXT, 'Name of the tag with this version'),
                'timecreated' => new external_value(PARAM_INT, 'Timestamp of version release'),
                'approved' => new external_value(PARAM_INT, 'Approval status'),
                'visible'  => new external_value(PARAM_BOOL, 'Visibility status'),
                'supportedmoodle' => new external_value(PARAM_TEXT, 'Comma separated list of support Moodle versions'),
                'downloadurl' => new external_value(PARAM_URL, 'Download URL'),
                'viewurl' => new external_value(PARAM_URL, 'View URL'),
                'smurfresult' => new external_value(PARAM_TEXT, 'Code prechecks results summary'),
            ])
        ),
    ])
);
</code>
 
==== Example cURL client fetching the list of maintained plugins  ====
 
<code bash>
#!/bin/bash
 
# Set your moodle.org username and password here.
USERNAME="your_username"
PASSWORD="your_password"
 
CURL="curl -s"
HOST=https://moodle.org
SERVICE=plugins_maintenance
FUNCTION=local_plugins_get_maintained_plugins
 
TOKEN=$(${CURL} "${HOST}/login/token.php" --data "username=${USERNAME}&password=${PASSWORD}&service=${SERVICE}" | jq --raw-output '.token')
 
${CURL} "${HOST}/webservice/rest/server.php" --data "wstoken=${TOKEN}&wsfunction=${FUNCTION}&moodlewsrestformat=json" | jq
</code>
 
=== Releasing a new version ===

Latest revision as of 05:13, 11 August 2023

Important:

This content of this page has been updated and migrated to the new Moodle Developer Resources. The information contained on the page should no longer be seen up-to-date.

Why not view this page on the new site and help us to migrate more content to the new site!