Skip to content

Conversation

@Jan-Schuppik
Copy link

@Jan-Schuppik Jan-Schuppik commented Aug 22, 2025

@Jan-Schuppik Jan-Schuppik requested a review from nilmerg August 22, 2025 13:51
@Jan-Schuppik Jan-Schuppik self-assigned this Aug 22, 2025
@cla-bot cla-bot bot added the cla/signed CLA is signed by all contributors of a PR label Aug 22, 2025
@Jan-Schuppik Jan-Schuppik force-pushed the feature/http-api-new-approach branch from 9a3a6aa to aa2b625 Compare August 25, 2025 12:48
Copy link
Member

@nilmerg nilmerg left a comment

Choose a reason for hiding this comment

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

This review covers only the early parts of routing and dispatching.

@nilmerg
Copy link
Member

nilmerg commented Aug 26, 2025

Oh, and I got the postgres tests working in my environment. Please get back to me for this.

Copy link
Contributor

@sukhwinder33445 sukhwinder33445 left a comment

Choose a reason for hiding this comment

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

I have looked at channels and contact tests so far, next I will look at contactgroup tests.

Copy link
Contributor

@sukhwinder33445 sukhwinder33445 left a comment

Choose a reason for hiding this comment

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

Please add following changes as well:

  • The PHPDoc for the method must contain a newline between different annotations, i.e. @param, @return.
  • Update method PHPDoc if required.
  • Make the getPlural() method protected.
  • Remove the resolved todos.

@Jan-Schuppik Jan-Schuppik force-pushed the feature/http-api-new-approach branch from 30b0b1b to da665ca Compare September 26, 2025 09:01
Copy link
Member

@nilmerg nilmerg left a comment

Choose a reason for hiding this comment

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

Let's discuss how we handle the openapi description and the usage of Swagger, as there are three possible solutions for me:

  • Caching (properly, not the way it's right now ;) )
  • CI (as your todo suggests)
  • Static (it's a versioned api after all)

Copy link
Member

Choose a reason for hiding this comment

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

Missing license header. It seems, not only this file is missing it, please make sure all PHP files have one.

@Jan-Schuppik Jan-Schuppik force-pushed the feature/http-api-new-approach branch from ad9e5e8 to 00d3880 Compare October 15, 2025 14:44
@Jan-Schuppik Jan-Schuppik force-pushed the feature/http-api-new-approach branch from 3863707 to 06a2750 Compare October 15, 2025 14:51
Copy link
Member

@nilmerg nilmerg left a comment

Choose a reason for hiding this comment

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

Don't worry, I didn't take a look at the validation/middleware stuff again 😜

@nilmerg
Copy link
Member

nilmerg commented Oct 21, 2025

Adjusted and extended the tests quite a bit. The failing tests uncover the following problems:

  • Invalid default channel or user UUIDs will result in a HTTP 400, whereas other errors like invalid group UUIDs or invalid address types result in a HTTP 422
  • An unknown channel UUID yields an incorrect error message
  • Changing group memberships through either the contacts or contact-groups endpoints is broken (as you've identified by yourself already)

foreach ($middlewares as $middleware) {
try {
$this->pipe($middleware);
} catch (\Exception $e) {
Copy link
Member

Choose a reason for hiding this comment

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

If you really must throw your own exception, catch TypeError instead

@@ -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


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.

Comment on lines 23 to 26
use Icinga\Module\Notifications\Model\Contactgroup;
use Icinga\Module\Notifications\Model\Rotation;
use Icinga\Module\Notifications\Model\RotationMember;
use Icinga\Module\Notifications\Model\RuleEscalationRecipient;
Copy link
Member

Choose a reason for hiding this comment

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

Just noticed. These must not be used! The ORM must be bypassed.

use Icinga\Exception\Json\JsonEncodeException;
use Icinga\Module\Notifications\Api\EndpointInterface;
use Icinga\Module\Notifications\Api\Exception\InvalidFilterParameterException;
use Icinga\Module\Notifications\Model\Contact;
Copy link
Member

Choose a reason for hiding this comment

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

Same here, plus the ones below, no ORM usage

@nilmerg nilmerg marked this pull request as ready for review October 22, 2025 07:35
$request
->withAttribute('version', ucfirst($version))
->withAttribute('endpoint', ucfirst($endpoint))
->withAttribute('identifier', $identifier)
Copy link
Member

Choose a reason for hiding this comment

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

MySQL uses a normal char(36), whereas PostgreSQL uses a native type, but only the native type is case-insensitive, so we should lowercase here. I think it's fine to do it here and assume everywhere else that it's already lowercase.

Copy link
Member

Choose a reason for hiding this comment

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

Oh and, not sure what the validation middleware accepts, but we have to also make sure the UUID is exactly 36 chars. (No curly braces)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla/signed CLA is signed by all contributors of a PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants