Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
138 commits
Select commit Hold shift + click to select a range
001cf17
Add: column external_uuid & missing column changed_at
Jan-Schuppik Sep 3, 2025
92778e1
Run with:
nilmerg Aug 11, 2025
8131fca
Introduce: PSR Logger
Jan-Schuppik Aug 22, 2025
f02e3f2
Fix: test-setup for MySQL compatibility (PostgreSQL tests still failing)
Jan-Schuppik Aug 14, 2025
a1b8b2b
Adjust: unit tests
Jan-Schuppik Aug 22, 2025
481f9df
Add: route for new api controller
Jan-Schuppik Aug 22, 2025
fc77a2c
Introduce: new API srtucture (starting with Contact GET)
Jan-Schuppik Aug 22, 2025
a7eb80b
Add: initial openapi docs
Jan-Schuppik Aug 22, 2025
df74d4e
Adjust: give the request object to ApiCore
Jan-Schuppik Aug 22, 2025
c219ea7
Fix: lint-errors & moduleName fetching
Jan-Schuppik Aug 25, 2025
07d3919
Remove: Icinga Web 2 BaseTestCase dependency
Jan-Schuppik Aug 25, 2025
2b7ee4c
Adjust: add small review suggestions
Jan-Schuppik Aug 28, 2025
710cf89
Rework: implements psr-15 RequestHandlerInterface
Jan-Schuppik Aug 29, 2025
5891dac
Adjust: api-version handling
Jan-Schuppik Sep 1, 2025
c772342
Fix: request validation & plural-GET result name & test permissions
Jan-Schuppik Sep 1, 2025
544c673
Adjust: openapi documentation creating & storing
Jan-Schuppik Sep 1, 2025
b846798
Fix: Psr-Logger exception-handling
Jan-Schuppik Sep 3, 2025
5664f94
Introduce: PUT method handling
Jan-Schuppik Sep 3, 2025
5bf799c
Adjust: Openapi Attributes (+ fix strings)
Jan-Schuppik Sep 3, 2025
cdfdfb3
Introduce: POST method handling
Jan-Schuppik Sep 3, 2025
bcb5e57
Fix: phpdocs of endpoint-methods
Jan-Schuppik Sep 3, 2025
cf63e87
Introduce: DELETE method handling
Jan-Schuppik Sep 3, 2025
dff73f0
WIP: introduce psr15 pipeline & validation middleware
Jan-Schuppik Sep 4, 2025
caa5ffd
Fix: contact tests (enable POST with identifier)
Jan-Schuppik Sep 4, 2025
40333b6
Fix: CodeSniffer Errors
Jan-Schuppik Sep 5, 2025
c97f42d
Add: contactgroup endpoint methods
Jan-Schuppik Sep 5, 2025
0e5c409
Fix: contactgroup tests
Jan-Schuppik Sep 5, 2025
eb198e2
Adjust: enriching of get-result-rows
Jan-Schuppik Sep 5, 2025
ca67141
Add: channel GET-methods
Jan-Schuppik Sep 5, 2025
a67cd65
Fix: wrong Uuid-class & filterString fetching
Jan-Schuppik Sep 5, 2025
ad08004
Add: channel tests (+ adjust channel filters)
Jan-Schuppik Sep 5, 2025
c89da33
Fix: add missing escape-signs in tests
Jan-Schuppik Sep 5, 2025
c466160
Fix: CodeSniffer Errors
Jan-Schuppik Sep 5, 2025
f8ebcde
Remove: error abstraction
Jan-Schuppik Sep 8, 2025
b2d7c7a
Adjust: channel-tests add second default channel
Jan-Schuppik Sep 8, 2025
03453a4
Remove: middleware & middleware-pipeline
Jan-Schuppik Sep 8, 2025
86f71d7
Fix: channel-tests
Jan-Schuppik Sep 9, 2025
1095d7c
Fix: contact-tests
Jan-Schuppik Sep 10, 2025
14f9eed
Fix: contacgroup-tests & contact-tests
Jan-Schuppik Sep 10, 2025
bde3390
Adjust: parse all exceptions in error response (temporary workaround)
Jan-Schuppik Sep 10, 2025
c67c059
Fix: CodeSniffer Errors
Jan-Schuppik Sep 10, 2025
f9a03c3
Adjust: create response only if necessary
Jan-Schuppik Sep 10, 2025
1d019f5
Fix: general request-body-validation
Jan-Schuppik Sep 10, 2025
2881291
Adjust: naming of multi-result-response
Jan-Schuppik Sep 11, 2025
b358f90
Fix: request-body-validation & error-throwing
Jan-Schuppik Sep 11, 2025
e051fef
Adjust: simplify response-creating
Jan-Schuppik Sep 11, 2025
f632d1e
Adjust: move openapi-logic from core to openapi-endpoint
Jan-Schuppik Sep 11, 2025
0a8c530
Fix: unit-tests & adjust behavior
Jan-Schuppik Sep 15, 2025
e3f631b
Adjust: simplify dispatching of ApiController
Jan-Schuppik Sep 18, 2025
23d4d7d
Adjust: change scope of allowedMethod & generator funcs
Jan-Schuppik Sep 18, 2025
5cb4fc1
Fix: small mistakes in endpoints openapi & contactgroups
Jan-Schuppik Sep 18, 2025
e97d98d
Add: methode to control the creation of a Response
Jan-Schuppik Sep 18, 2025
4dc3803
Adjust: apply review suggestions to tests
Jan-Schuppik Sep 18, 2025
97423fb
Adjust: 'expected' variables in test
Jan-Schuppik Sep 18, 2025
f3e550a
Adjust: db usage & move general handle-logic to core
Jan-Schuppik Sep 19, 2025
49efec2
Remove: http error code 409
Jan-Schuppik Sep 19, 2025
3009ae1
Adjust: change endpoint const in abstract method
Jan-Schuppik Sep 19, 2025
c2b7fda
Fix: change unclear test names
Jan-Schuppik Sep 19, 2025
32a87ee
Adjust: Http enum creation
Jan-Schuppik Sep 19, 2025
9d24f14
Remove: plural-check from ApiCore and handle it in endpoints
Jan-Schuppik Sep 19, 2025
4018274
Fix: base assertValidRequest shouldn't provide logic
Jan-Schuppik Sep 19, 2025
9b7a3c9
Adjust: beautify filter assembling for plural get
Jan-Schuppik Sep 19, 2025
ad2861d
Adjust: json string creation
Jan-Schuppik Sep 19, 2025
0d3bcc1
Remove: unnecessary stream-request-body method
Jan-Schuppik Sep 19, 2025
ecf502a
Fix: move request asserting to from core to v1
Jan-Schuppik Sep 19, 2025
b91a66f
Adjust: replace PHP-docs with more descriptive test-names
Jan-Schuppik Sep 19, 2025
584ac80
Fix: change remaining test-UUID to constants
Jan-Schuppik Sep 22, 2025
2525735
Adjust: review suggestions
Jan-Schuppik Sep 25, 2025
aa43277
Fix: wrong format of endpoint
Jan-Schuppik Sep 25, 2025
c8191d0
Fix: mysql external_uuid db type
Jan-Schuppik Sep 25, 2025
d515000
Fix: cases of class-call in dispatching
Jan-Schuppik Sep 25, 2025
22c102e
Adjust: response header content-type
Jan-Schuppik Sep 26, 2025
6a5b374
Fix: Code-Sniffer Errors
Jan-Schuppik Sep 26, 2025
96e1ad5
Adjust: cleanup row preparation for output
Jan-Schuppik Sep 26, 2025
b9c5747
Adjust: improve the php-docs
Jan-Schuppik Sep 26, 2025
ab22f12
Adjust: cleanup code & set response-header if not provided
Jan-Schuppik Sep 26, 2025
5393d81
Adjust: return response instead of assoc array in endpoint-methods
Jan-Schuppik Sep 29, 2025
1b10084
Fix: change unsuitable names
Jan-Schuppik Sep 29, 2025
8d4c69e
Fix: correct indentations
Jan-Schuppik Sep 29, 2025
1d71c5c
Adjust: use sprintf() to cleanup strings
Jan-Schuppik Sep 29, 2025
c1d2197
Remove: TODOs
Jan-Schuppik Sep 29, 2025
b22fbe8
Adjust: identifier-check in post-methods
Jan-Schuppik Sep 29, 2025
3d9aa4f
Fix: scope of variables initialized in if-condition
Jan-Schuppik Sep 29, 2025
a9cf9ba
Fix: add spacing to improve readability
Jan-Schuppik Sep 29, 2025
e05c915
Fix: IDE warnings
Jan-Schuppik Sep 29, 2025
82a28be
Adjust: use database via singleton instead of initialize variables
Jan-Schuppik Sep 29, 2025
d75633e
Fix: exceeding line
Jan-Schuppik Sep 29, 2025
25909c2
Fix: unit-tests for new database-trait
Jan-Schuppik Sep 29, 2025
d8af316
Fix: scope of a variable
Jan-Schuppik Sep 30, 2025
154fe88
Adjust: make unit-tests independent
Jan-Schuppik Sep 30, 2025
8813ec1
Fix: use getConnection() (need ipl-sql shared-test-databases updated)
Jan-Schuppik Sep 30, 2025
fba9c10
Fix: unit-test errors caused by databases
Jan-Schuppik Oct 1, 2025
53784c3
Revert "Fix: unit-test errors caused by databases"
Jan-Schuppik Oct 2, 2025
4e94dee
Introduce and use new `ApiTestBackends` data provider
nilmerg Oct 2, 2025
e965792
Fix: unit-tests according to new data provider
Jan-Schuppik Oct 6, 2025
fcd79f2
Fix: Code-Sniffer Errors
Jan-Schuppik Oct 6, 2025
5959e1f
Fix: softdelete-blocks-uuid problem
Jan-Schuppik Oct 7, 2025
7bba0f1
php: Spin up database backends for unit tests
nilmerg Oct 8, 2025
048e39b
tests: Set up Icinga Web Database
nilmerg Oct 8, 2025
32b78fe
ApiTestBackends: Pass through `ICINGAWEB_LIBDIR` to webserver
nilmerg Oct 8, 2025
7cdbe98
Adjust: implement HandlerInterface in endpoints instead of in base class
Jan-Schuppik Oct 10, 2025
8850461
Fix: Error-handling, log no-http-errors
Jan-Schuppik Oct 10, 2025
c864495
Fix: psr logger
Jan-Schuppik Oct 10, 2025
9e5bd80
Fix: stream the response
Jan-Schuppik Oct 10, 2025
481cb98
Fix: ServerRequest creation, avoid Content-type checking
Jan-Schuppik Oct 14, 2025
4a9f31e
Fix: web-forms add column external_uuid
Jan-Schuppik Oct 14, 2025
40cc67a
Adjust: wrapping-condition of result data in tests
Jan-Schuppik Oct 14, 2025
a751d49
Fix: HttpMethod enum
Jan-Schuppik Oct 14, 2025
bb966be
Adjust: check if http method exists for endpoint
Jan-Schuppik Oct 14, 2025
8beb160
Add: license headers
Jan-Schuppik Oct 15, 2025
5494522
Adjust: replace PHP-docs with more descriptive test-names
Jan-Schuppik Sep 19, 2025
697c98c
Introduce: own handling of swagger-php attributes (start with GET)
Jan-Schuppik Sep 24, 2025
70d73eb
Add: DELETE swagger-php attributes
Jan-Schuppik Sep 24, 2025
6289d7e
Add: POST swagger-php attributes
Jan-Schuppik Oct 1, 2025
ff4188f
Add: PUT swagger-php attributes
Jan-Schuppik Oct 1, 2025
c0fe743
WIP: Adjust openapi description according to schemathesis checks
Jan-Schuppik Oct 9, 2025
e06838d
Adjust: cleanup OpenApi Description
Jan-Schuppik Oct 10, 2025
26307e8
Adjust: give the POST request body a new uuid
Jan-Schuppik Oct 15, 2025
3526533
Fix: standardize the designation of Contact Groups
Jan-Schuppik Oct 15, 2025
c774c90
Fix: output format of a single get result
Jan-Schuppik Oct 15, 2025
00d3880
Add: missing license headers (to OAD files)
Jan-Schuppik Oct 15, 2025
06a2750
Fix: Codesniffer errors
Jan-Schuppik Oct 15, 2025
1b8fe70
Fix: rename API directories
Jan-Schuppik Oct 16, 2025
f051084
Introduce: Middleware Pipeline
Jan-Schuppik Oct 16, 2025
f60325e
tests: Enhance/Cleanup ApiV1ContactsTest
nilmerg Oct 21, 2025
9fdaafd
tests: Enhance/Cleanup ApiV1ContactGroupsTest
nilmerg Oct 21, 2025
2a1c897
tests: Check whether the api updates group memberships properly
nilmerg Oct 21, 2025
9236559
ApiTestBackends: Log to a file instead
nilmerg Oct 21, 2025
78b9ec6
tests: Check whether the api updates addresses properly
nilmerg Oct 21, 2025
579e306
tests: Use assertJsonStringEqualsJsonString where applicable
nilmerg Oct 21, 2025
6989c24
test: Fix codestyle in ApiV1ContactsTest
nilmerg Oct 21, 2025
121835e
Adjust: beautify Middleware & Pipeline
Jan-Schuppik Oct 17, 2025
c89072c
Fix: updating contactgroup_member via contactgroups-PUT
Jan-Schuppik Oct 17, 2025
4d49399
Fix: updating contactgroup_member via contacts-PUT
Jan-Schuppik Oct 21, 2025
001d2d8
Fix: OAD headers
Jan-Schuppik Oct 21, 2025
7f05397
Adjust: create OAD via cli-command
Jan-Schuppik Oct 21, 2025
ebdd397
Fix: problems from reviews
Jan-Schuppik Oct 21, 2025
aeb8568
Fix: endpoint behavior according to unit-tests
Jan-Schuppik Oct 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
154 changes: 154 additions & 0 deletions application/clicommands/OpenapiCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
<?php

namespace Icinga\Module\Notifications\Clicommands;

use FilesystemIterator;
use Icinga\Application\Icinga;
use Icinga\Cli\Command;
use Icinga\Module\Notifications\Api\OpenApiPreprocessor\AddGlobal401Response;
use Icinga\Module\Notifications\Common\PsrLogger;
use OpenApi\Generator;
use RecursiveDirectoryIterator;
use RecursiveIteratorIterator;
use RuntimeException;
use SplFileInfo;
use Throwable;

class OpenapiCommand extends Command
{
public function runAction(): void
{
echo "\n\n\ntest\n\n\n";
}

public function generateAction(): void
{

/**
* CLI tool to generate an OpenAPI JSON file from PHP attributes using swagger-php.
*
* Usage:
* icingacli openapi generate \
* --dir ./src \
* --exclude vendor,tests \
* --include ApiController.php,UserController.php \
* --output ./docs/openapi.json \
* --api-version v1
* --oad-version 3.1.0
*/

$directoryInNotifications = $this->params->get('dir', '/library/Notifications/Api/');
$exclude = $this->params->get('exclude');
$include = $this->params->get('include');
$outputPath = $this->params->get('output');
$apiVersion = $this->params->get('api-version', 'v1');
$oadVersion = $this->params->get('oad-version', '3.1.0');

$notificationsPath = Icinga::app()->getModuleManager()->getModule('notifications')->getBaseDir();
$directory = $notificationsPath . $directoryInNotifications;

Check failure on line 48 in application/clicommands/OpenapiCommand.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.2 on ubuntu-latest

Binary operation "." between string and mixed results in an error.

Check failure on line 48 in application/clicommands/OpenapiCommand.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.4 on ubuntu-latest

Binary operation "." between string and mixed results in an error.

Check failure on line 48 in application/clicommands/OpenapiCommand.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.3 on ubuntu-latest

Binary operation "." between string and mixed results in an error.

$baseDirectory = realpath($directory);
if ($baseDirectory === false || !is_dir($baseDirectory)) {
throw new RuntimeException("Invalid directory: {$directory}");
}

$exclude = isset($exclude) ? array_map('trim', explode(',', $exclude)) : [];

Check failure on line 55 in application/clicommands/OpenapiCommand.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.2 on ubuntu-latest

Parameter #2 $string of function explode expects string, mixed given.

Check failure on line 55 in application/clicommands/OpenapiCommand.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.4 on ubuntu-latest

Parameter #2 $string of function explode expects string, mixed given.

Check failure on line 55 in application/clicommands/OpenapiCommand.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.3 on ubuntu-latest

Parameter #2 $string of function explode expects string, mixed given.
$include = isset($include) ? array_map('trim', explode(',', $include)) : [];

Check failure on line 56 in application/clicommands/OpenapiCommand.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.2 on ubuntu-latest

Parameter #2 $string of function explode expects string, mixed given.

Check failure on line 56 in application/clicommands/OpenapiCommand.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.4 on ubuntu-latest

Parameter #2 $string of function explode expects string, mixed given.

Check failure on line 56 in application/clicommands/OpenapiCommand.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.3 on ubuntu-latest

Parameter #2 $string of function explode expects string, mixed given.
$outputPath = $notificationsPath . ($outputPath ?? '/doc/api/api-' . $apiVersion . '-public.json');

Check failure on line 57 in application/clicommands/OpenapiCommand.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.2 on ubuntu-latest

Binary operation "." between string and mixed results in an error.

Check failure on line 57 in application/clicommands/OpenapiCommand.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.2 on ubuntu-latest

Binary operation "." between '/doc/api/api-' and mixed results in an error.

Check failure on line 57 in application/clicommands/OpenapiCommand.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.4 on ubuntu-latest

Binary operation "." between string and mixed results in an error.

Check failure on line 57 in application/clicommands/OpenapiCommand.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.4 on ubuntu-latest

Binary operation "." between '/doc/api/api-' and mixed results in an error.

Check failure on line 57 in application/clicommands/OpenapiCommand.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.3 on ubuntu-latest

Binary operation "." between string and mixed results in an error.

Check failure on line 57 in application/clicommands/OpenapiCommand.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.3 on ubuntu-latest

Binary operation "." between '/doc/api/api-' and mixed results in an error.

$files = $this->collectPhpFiles($baseDirectory, $exclude, $include);

echo "→ Scanning directory: $baseDirectory\n";
echo "→ Found " . count($files) . " PHP files\n";
// die;

$generator = new Generator(new PsrLogger());
$generator->setVersion($oadVersion);

Check failure on line 66 in application/clicommands/OpenapiCommand.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.2 on ubuntu-latest

Parameter #1 $version of method OpenApi\Generator::setVersion() expects string|null, mixed given.

Check failure on line 66 in application/clicommands/OpenapiCommand.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.4 on ubuntu-latest

Parameter #1 $version of method OpenApi\Generator::setVersion() expects string|null, mixed given.

Check failure on line 66 in application/clicommands/OpenapiCommand.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.3 on ubuntu-latest

Parameter #1 $version of method OpenApi\Generator::setVersion() expects string|null, mixed given.
$generator->getProcessorPipeline()->add(new AddGlobal401Response());

try {
$openapi = $generator->generate($files);

$json = $openapi->toJson(

Check failure on line 72 in application/clicommands/OpenapiCommand.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.2 on ubuntu-latest

Cannot call method toJson() on OpenApi\Annotations\OpenApi|null.

Check failure on line 72 in application/clicommands/OpenapiCommand.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.4 on ubuntu-latest

Cannot call method toJson() on OpenApi\Annotations\OpenApi|null.

Check failure on line 72 in application/clicommands/OpenapiCommand.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.3 on ubuntu-latest

Cannot call method toJson() on OpenApi\Annotations\OpenApi|null.
JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_INVALID_UTF8_IGNORE | JSON_PRETTY_PRINT
);

$dir = dirname($outputPath);
if (!is_dir($dir)) {
mkdir($dir, 0755, true);
}

file_put_contents($outputPath, $json);

echo "✅ OpenAPI documentation written to: $outputPath\n";
} catch (Throwable $e) {
fwrite(STDERR, "❌ Error generating OpenAPI: " . $e->getMessage() . "\n");
exit(1);
}
}

/**
* Recursively scan a directory for PHP files.
*/
function collectPhpFiles(string $baseDirectory, array $exclude, array $include): array

Check failure on line 93 in application/clicommands/OpenapiCommand.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.2 on ubuntu-latest

Method Icinga\Module\Notifications\Clicommands\OpenapiCommand::collectPhpFiles() return type has no value type specified in iterable type array.

Check failure on line 93 in application/clicommands/OpenapiCommand.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.2 on ubuntu-latest

Method Icinga\Module\Notifications\Clicommands\OpenapiCommand::collectPhpFiles() has parameter $include with no value type specified in iterable type array.

Check failure on line 93 in application/clicommands/OpenapiCommand.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.2 on ubuntu-latest

Method Icinga\Module\Notifications\Clicommands\OpenapiCommand::collectPhpFiles() has parameter $exclude with no value type specified in iterable type array.

Check failure on line 93 in application/clicommands/OpenapiCommand.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.4 on ubuntu-latest

Method Icinga\Module\Notifications\Clicommands\OpenapiCommand::collectPhpFiles() return type has no value type specified in iterable type array.

Check failure on line 93 in application/clicommands/OpenapiCommand.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.4 on ubuntu-latest

Method Icinga\Module\Notifications\Clicommands\OpenapiCommand::collectPhpFiles() has parameter $include with no value type specified in iterable type array.

Check failure on line 93 in application/clicommands/OpenapiCommand.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.4 on ubuntu-latest

Method Icinga\Module\Notifications\Clicommands\OpenapiCommand::collectPhpFiles() has parameter $exclude with no value type specified in iterable type array.

Check failure on line 93 in application/clicommands/OpenapiCommand.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.3 on ubuntu-latest

Method Icinga\Module\Notifications\Clicommands\OpenapiCommand::collectPhpFiles() return type has no value type specified in iterable type array.

Check failure on line 93 in application/clicommands/OpenapiCommand.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.3 on ubuntu-latest

Method Icinga\Module\Notifications\Clicommands\OpenapiCommand::collectPhpFiles() has parameter $include with no value type specified in iterable type array.

Check failure on line 93 in application/clicommands/OpenapiCommand.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.3 on ubuntu-latest

Method Icinga\Module\Notifications\Clicommands\OpenapiCommand::collectPhpFiles() has parameter $exclude with no value type specified in iterable type array.
{
$baseDirectory = rtrim($baseDirectory, '/') . '/';
if (! is_dir($baseDirectory)) {
throw new RuntimeException("Directory $baseDirectory does not exist");
}
if (! is_readable($baseDirectory)) {
throw new RuntimeException("Directory $baseDirectory is not readable");
}

$files = [];
$iterator = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($baseDirectory, FilesystemIterator::SKIP_DOTS)
);

// echo PHP_EOL;
// var_dump($iterator);
// echo PHP_EOL . PHP_EOL;
// die();

/** @var SplFileInfo $file */
foreach ($iterator as $file) {
if (! $file->isFile() || $file->getExtension() !== 'php') {
continue;
}

$path = $file->getPathname();

// Exclude
if ($exclude !== [] && $this->matchesAnyPattern($path, $exclude)) {
continue;
}

// Include filter (if defined)
if ($include !== [] && ! $this->matchesAnyPattern($path, $include)) {
continue;
}

$files[] = $path;
}

if (empty($files)) {
throw new RuntimeException("No PHP files found in $baseDirectory");
}

return $files;
}
//
function matchesAnyPattern(string $string, array $patterns): bool
{
foreach ($patterns as $pattern) {
// Escape regex special chars except for '*'
$regex = '/^' . str_replace('\*', '.*', preg_quote($pattern, '/')) . '$/';
// echo PHP_EOL . $regex . PHP_EOL; die;
if (preg_match($regex, $string)) {
return true;
}
}

return false;
}
}
31 changes: 31 additions & 0 deletions doc/20-REST-API.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# REST API

The Icinga Notifications module provides a REST API that allows you to manage notification-related resources programmatically.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Icinga Notifications module Icinga Notifications Web


With this API, you can:
- Manage **contacts** and **contact groups**
- Read available **notification channels**

This API enables easy integration with external tools, automation workflows, and configuration management systems.

---
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These look weird, how did you come up using them? I'd rather remove them

image


## API Versioning

The Notifications API follows a **versioned** structure to ensure backward compatibility and predictable upgrades.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before

this API

This API

And now

Notifications API

Later

… API … reference

Please stick to a single version, so remove Notifications here.


The current and first stable version is: /icingaweb2/notifications/api/v1

Future versions will be accessible under corresponding paths (for example, `/api/v2`), allowing you to migrate at your own pace.

---

## API Description

The complete API reference for version `v1` is available in [`api/v1.md`](api/v1.md).

It contains an OpenAPI v3.1 description with detailed information about all endpoints, including:
- Request and response schemas
- Example payloads
- Authentication requirements
- Error handling
Loading
Loading