API call (REST?) to trigger "Apply config"?

is there any ability, or API Endpoint (REST) available that can perform the equivalent of a human pressing “Apply config” in the web browser?

I know that there is amportal reload or /var/lib/asterisk/bin/module_admin reload, howver I dont want to have to Cron this, and would much rather only call it when necessary.

Use Case:
with the newest update to the queues module, and the ability to SET members of a queue, we gave our staff a google doc wherein they can enter their extension, push a button, and it will populate their extension into the dynamic members of their queue.
This is much safer than giving them the keys to the kingdom and a full web account.
however, the last step we do is push this code into freePBX… and then contact a human to press “Apply Config” for you.
thats easy to program… if an endpoint exists.

fwconsole r

https://wiki.freepbx.org/display/FPG/API

https://wiki.sangoma.com/display/FPG/Framework+Module+GraphQL+APIs#FrameworkModuleGraphQLAPIs-Performreload

1 Like

As @PitzKey noted :arrow_up: there is a GraphQL method for doing apply config. It forms part of @gblumenthal’s recent GraphQL tutorial:
https://wiki.freepbx.org/display/FDT/FreePBX+GraphQL+Provisioning+Tutorial#FreePBXGraphQLProvisioningTutorial-Applyingconfiguration

You need the latest edge version of the API module in 15.

1 Like

Very nice and detailed tutorial, @gblumenthal! Great job!

1 Like

fwconsole r

fwconsole is not a web accessible API.

@lgaetz Graphql is interesting… but is there not a REST endpoint that i can post to to trigger the same?
it seems odd to me that such key functionality would be missing from the REST api.

It’s trivial… you can build some REST around the single function call:

<?php

$bootstrap_settings['freepbx_auth'] = false;
require_once '/etc/freepbx.conf';

do_reload();

?>
1 Like

In the same link I posted above:

https://wiki.freepbx.org/display/FPG/REST+API

1 Like

Thank you @PitzKey.
it does seem that I MIGHT be able to post to http://{REDACTED}/admin/api/api/gql
with a doreload…

However, ive hit another stumbling block:
doreload is not a function in the “Current” api module, 15.0.10
this was mentioned above, however, while trying to upgrade to the edge track…
fwconsole ma upgrade api --edge
only gives

No repos specified, using: [standard,extended,unsupported,commercial,edge] from last GUI settings

api is the same as the online version, unable to upgrade
Updating Hooks...Done
Chowning directories...Done

which puts my version to 15.0.3.11

im sure im doing something wrong here, but i just cant seem to find it. 15.0.3.11 would be Older than 15.0.10

Any chance you could lend some advice as to why im not able to install the edge API module?

The current edge version of API right now is 15.0.3.11. That is the most recent.

thanks @lgaetz… but after using the CLI to upgrade to 15.0.3.11, i still dont have access to the new functionality, even in the API Explorer as linked previously.

other than a core reload… what am i missing for getting the new version “active”?

its not showing as the active version in my web interface either, only 15.0.10

an asterisk -r core reload hasnt helped
nor has a fwconsole reload

No repos specified, using: [standard,extended,unsupported,commercial,edge] from last GUI settings

+----------------------+------------+-------------------------------------+-------------+
| Module               | Version    | Status                              | License     |
+----------------------+------------+-------------------------------------+-------------+
| accountcodepreserve  | 13.0.2.2   | Enabled                             | GPLv2       |
| amd                  | 15.0.2     | Enabled                             | GPLv3+      |
| announcement         | 15.0.3.10  | Enabled                             | GPLv3+      |
| api                  | 15.0.3.11  | Enabled                             | AGPLv3+     |

but GUI still lists:

ModuleVersionPublisherLicenseStatusTrack 
 Asterisk API15.0.10StableSangoma Technologies CorporationGPLv2+Enabled

please disregard… I was loooning at the Asterisk API module,not PBX API.
I am indeed on 15.0.3.11 for PBX API now.

that being said, the
Connectivity > API > GraphQL Explorer still does not list or accept the commands as listed in the linked doc…

Circling back on this - it was a server issue.

To run a GraphQL doreload, send a POST to http://{{ server }}/admin/api/api/gql
with

--form 'query="mutation {
  doreload(input: {}) {
    message
    status
    transaction_id
  }
}"'

or

--data-raw '{"query":"mutation {\n  doreload(input: {}) {\n    message\n    status\n    transaction_id\n  }\n}","variables":{}}'
3 Likes

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.