Skip to content

Commit 52b5730

Browse files
committed
Initial Release
1 parent 3efe1a3 commit 52b5730

File tree

11 files changed

+205
-26
lines changed

11 files changed

+205
-26
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/vendor/
2+
.*
3+
!.gitignore

LICENSE

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,10 @@
1-
This is free and unencumbered software released into the public domain.
2-
3-
Anyone is free to copy, modify, publish, use, compile, sell, or
4-
distribute this software, either in source code form or as a compiled
5-
binary, for any purpose, commercial or non-commercial, and by any
6-
means.
7-
8-
In jurisdictions that recognize copyright laws, the author or authors
9-
of this software dedicate any and all copyright interest in the
10-
software to the public domain. We make this dedication for the benefit
11-
of the public at large and to the detriment of our heirs and
12-
successors. We intend this dedication to be an overt act of
13-
relinquishment in perpetuity of all present and future rights to this
14-
software under copyright law.
15-
16-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19-
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20-
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21-
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22-
OTHER DEALINGS IN THE SOFTWARE.
23-
24-
For more information, please refer to <https://unlicense.org>
1+
Permission to use, copy, modify, and/or distribute this software for
2+
any purpose with or without fee is hereby granted.
3+
4+
THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL
5+
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
6+
OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE
7+
FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
8+
DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
9+
AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
10+
OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

README.md

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,27 @@
1-
# plugin-interfaces
2-
Interfaces for LibreNMS plugins
1+
# LibreNMS Plugin Interfaces
2+
3+
Create a new Laravel Package as described:
4+
https://laravel.com/docs/packages
5+
6+
Require this package
7+
8+
composer require librenms/plugin-interfaces
9+
10+
11+
Register your plugin with LibreNMS in your provider boot method and check to see if it is enabled:
12+
13+
```php
14+
public function boot(): void
15+
{
16+
$pluginName = 'example-plugin';
17+
$pluginManager = $this->app->make(\LibreNMS\Interfaces\Plugins\PluginManagerInterface::class);
18+
19+
$pluginManager->publishHook($pluginName, \LibreNMS\Interfaces\Plugins\MenuEntryHook::class, MenuEntryHook::class);
20+
21+
if (! $pluginManager->pluginEnabled($pluginName)) {
22+
return; // if plugin is disabled, don't boot
23+
}
24+
25+
// Do regular Laravel Package actions here, such as register routes and views or publish files.
26+
}
27+
```

composer.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "librenms/plugin-interfaces",
3+
"description": "Interfaces required to create a LibreNMS Plugin",
4+
"type": "library",
5+
"license": "Zero-Clause BSD",
6+
"homepage": "https://www.librenms.org/",
7+
"autoload": {
8+
"psr-4": {
9+
"LibreNMS\\Interfaces\\Plugins\\": "src/"
10+
}
11+
},
12+
"require": {
13+
"php": ">=7.1"
14+
}
15+
}

src/Hook.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
4+
namespace LibreNMS\Interfaces\Plugins;
5+
6+
interface Hook
7+
{
8+
/**
9+
* Will be called by the plugin manager to check if the user is authorized. Will be called with Dependency Injection.
10+
*/
11+
// public function authorize(): bool;
12+
13+
/**
14+
* Will be called by the plugin manager to execute this plugin at the correct time. Will be called with Dependency Injection.
15+
* Available variables for injection: $pluginName, $settings
16+
*
17+
*/
18+
// public function handle();
19+
}

src/Hooks/DeviceOverviewHook.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace LibreNMS\Interfaces\Plugins\Hooks;
4+
5+
use LibreNMS\Interfaces\Plugins\Hook;
6+
7+
interface DeviceOverviewHook extends Hook
8+
{
9+
10+
}

src/Hooks/MenuEntryHook.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace LibreNMS\Interfaces\Plugins\Hooks;
4+
5+
use LibreNMS\Interfaces\Plugins\Hook;
6+
7+
interface MenuEntryHook extends Hook
8+
{
9+
10+
}

src/Hooks/PortTabHook.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace LibreNMS\Interfaces\Plugins\Hooks;
4+
5+
use LibreNMS\Interfaces\Plugins\Hook;
6+
7+
interface PortTabHook extends Hook
8+
{
9+
10+
}

src/Hooks/SettingsHook.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace LibreNMS\Interfaces\Plugins\Hooks;
4+
5+
use LibreNMS\Interfaces\Plugins\Hook;
6+
7+
interface SettingsHook extends Hook
8+
{
9+
10+
}

src/Hooks/SinglePageHook.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace LibreNMS\Interfaces\Plugins\Hooks;
4+
5+
use LibreNMS\Interfaces\Plugins\Hook;
6+
7+
interface SinglePageHook extends Hook
8+
{
9+
10+
}

0 commit comments

Comments
 (0)