mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Added new api route for billing
This commit is contained in:
@ -45,6 +45,10 @@ $app->group('/api', function() use ($app) {
|
|||||||
$app->group('/portgroups', function() use ($app) {
|
$app->group('/portgroups', function() use ($app) {
|
||||||
$app->get('/:group', 'authToken', 'get_graph_by_portgroup')->name('get_graph_by_portgroup');//api/v0/portgroups/$group
|
$app->get('/:group', 'authToken', 'get_graph_by_portgroup')->name('get_graph_by_portgroup');//api/v0/portgroups/$group
|
||||||
});
|
});
|
||||||
|
$app->group('/bills', function() use ($app) {
|
||||||
|
$app->get('/:bill_id', 'authToken', 'list_bills')->name('get_bill');//api/v0/bills/$bill_id
|
||||||
|
});
|
||||||
|
$app->get('/bills', 'authToken', 'list_bills')->name('list_bills');//api/v0/bills
|
||||||
});
|
});
|
||||||
$app->get('/v0', 'authToken', 'show_endpoints');//api/v0
|
$app->get('/v0', 'authToken', 'show_endpoints');//api/v0
|
||||||
});
|
});
|
||||||
|
@ -465,3 +465,33 @@ function get_port_graphs() {
|
|||||||
$app->response->headers->set('Content-Type', 'application/json');
|
$app->response->headers->set('Content-Type', 'application/json');
|
||||||
echo _json_encode($output);
|
echo _json_encode($output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function list_bills() {
|
||||||
|
global $config;
|
||||||
|
$app = \Slim\Slim::getInstance();
|
||||||
|
$router = $app->router()->getCurrentRoute()->getParams();
|
||||||
|
$bill_id = $router['bill_id'];
|
||||||
|
if(isset($_GET['custid'])) {
|
||||||
|
$sql = "`bill_custid` = ?";
|
||||||
|
$param = array($_GET['custid']);
|
||||||
|
} elseif(isset($_GET['ref'])) {
|
||||||
|
$sql = "`bill_ref` = ?";
|
||||||
|
$param = array($_GET['ref']);
|
||||||
|
} elseif(is_numeric($bill_id)) {
|
||||||
|
$sql = "`bill_id` = ?";
|
||||||
|
$param = array($bill_id);
|
||||||
|
} else {
|
||||||
|
$sql = "";
|
||||||
|
$param = array();
|
||||||
|
}
|
||||||
|
if(count($param) >= 1) {
|
||||||
|
$sql = "WHERE $sql";
|
||||||
|
}
|
||||||
|
$bills = dbFetchRows("SELECT * FROM `bills` $sql",$param);
|
||||||
|
$total_bills = count($bills);
|
||||||
|
$output = array("status" => "ok", "err-msg" => '', "count" => $total_bills, "bills" => $bills);
|
||||||
|
$app->response->setStatus('200');
|
||||||
|
$app->response->headers->set('Content-Type', 'application/json');
|
||||||
|
echo _json_encode($output);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -319,11 +319,52 @@ if ($_SESSION['userlevel'] == '10')
|
|||||||
<tr>
|
<tr>
|
||||||
<td colspan="5"><code>curl -H "X-Auth-Token: 91c60e737e342c205be5bba8e2954d27" \<br/> "https://librenms.example.com/api/v0/devices/localhost/ports?columns=ifDescr,ifName"</code></td>
|
<td colspan="5"><code>curl -H "X-Auth-Token: 91c60e737e342c205be5bba8e2954d27" \<br/> "https://librenms.example.com/api/v0/devices/localhost/ports?columns=ifDescr,ifName"</code></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr class="success">
|
||||||
|
<td colspan="5"><strong>List Bills</strong></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>/api</td>
|
||||||
|
<td>/v0</td>
|
||||||
|
<td>/bills</td>
|
||||||
|
<td>
|
||||||
|
<ul class="list-unstyled">
|
||||||
|
<li>custid = the customer reference for the bill</li>
|
||||||
|
<li>ref = the billing reference for the bill</li>
|
||||||
|
</ul>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
JSON
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="5"><code>curl -H "X-Auth-Token: 91c60e737e342c205be5bba8e2954d27" \<br/> "https://librenms.example.com/api/v0/bills"</code></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="5"><code>curl -H "X-Auth-Token: 91c60e737e342c205be5bba8e2954d27" \<br/> "https://librenms.example.com/api/v0/bills?custid=Testing"</code></td>
|
||||||
|
</tr>
|
||||||
|
<tr class="success">
|
||||||
|
<td colspan="5"><strong>Retrieve Bill information</strong></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>/api</td>
|
||||||
|
<td>/v0</td>
|
||||||
|
<td>/bills/$bill_id</td>
|
||||||
|
<td>
|
||||||
|
<ul class="list-unstyled">
|
||||||
|
</ul>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
JSON
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="5"><code>curl -H "X-Auth-Token: 91c60e737e342c205be5bba8e2954d27" \<br/> "https://librenms.example.com/api/v0/bills/$bill_id"</code></td>
|
||||||
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-3">
|
<div class="col-sm-3">
|
||||||
<div class="bs-docs-sidebar hidden-print hidden-xs hidden-sm affix" id="sidebar" role="complementary">
|
<div class="bs-docs-sidebar hidden-print hidden-xs hidden-sm affix" id="sidebar" role="complementary">
|
||||||
<ul class="nav bs-docs-sidenav">
|
<ul class="nav bs-docs-sidenav">
|
||||||
<li><a href="api-docs/#intro">Introduction</a></li>
|
<li><a href="api-docs/#intro">Introduction</a></li>
|
||||||
<li><a href="api-docs/#tokens">Token authentication</a></li>
|
<li><a href="api-docs/#tokens">Token authentication</a></li>
|
||||||
|
Reference in New Issue
Block a user