Skip to content

Conversation

@gam6itko
Copy link
Contributor

@gam6itko gam6itko commented Nov 7, 2025

✨ Key Changes

  1. Added AbstractLapiClient

    • Extracted common logic for interacting with the LAPI (initialization, HTTP requests, response/error handling).
    • Reduced code duplication across clients.
  2. Added AlertsClient

    • New client for managing LAPI alerts endpoints.

    • Implemented methods:

      • listAlerts() — retrieve a list of alerts;
      • getAlertById(int $id) — fetch a specific alert by ID;
      • createAlert(array $data) — create a new alert;
      • deleteAlert(int $id) — delete an alert;
      • (add any other methods if applicable, e.g., update, filter, search, etc.)
  3. Added integration tests for AlertsClient

    • Covers real (or mocked) interactions with the LAPI;
    • Tests alert creation, retrieval, and deletion flows.
  4. Added WatcherClient

    • Provides authentication for “watcher” clients;
    • Handles token retrieval and renewal.
  5. Added BouncerClient

    • Introduced for consistency across all LAPI clients;
    • The old Bouncer class is now marked as deprecated and will be removed in a future release.

@gam6itko gam6itko marked this pull request as draft November 8, 2025 16:26
@gam6itko gam6itko marked this pull request as ready for review November 10, 2025 19:00
@gam6itko
Copy link
Contributor Author

I don't know how to fix rest of pipelines

@julienloizelet julienloizelet self-requested a review November 11, 2025 00:06
@julienloizelet julienloizelet self-assigned this Nov 11, 2025
@julienloizelet
Copy link
Collaborator

Hi @gam6itko,

Thanks for this PR.

May I ask why you need a Watcher client ? Do you have a use case ?

Thanks

@gam6itko
Copy link
Contributor Author

Hi @gam6itko,

Thanks for this PR.

May I ask why you need a Watcher client ? Do you have a use case ?

Thanks

It’s needed to get the authentication token and use it within the TokenStorageInterface. This follows the Dependency Inversion Principle (DIP). I also plan to implement the remaining methods (allowlist) in the future.
If this is done in every method, it may lead to code duplication.

@julienloizelet
Copy link
Collaborator

Hi @gam6itko,
Thanks for this PR.
May I ask why you need a Watcher client ? Do you have a use case ?
Thanks

It’s needed to get the authentication token and use it within the TokenStorageInterface. This follows the Dependency Inversion Principle (DIP). I also plan to implement the remaining methods (allowlist) in the future. If this is done in every method, it may lead to code duplication.

My question was more about the fact that, until now, this library has only been used for bouncing purposes. The Watcher client is not intended for bouncing, so in what context do you want to use it? Is it to have a separate log processor or something?

Thanks

@gam6itko
Copy link
Contributor Author

gam6itko commented Nov 15, 2025

My question was more about the fact that, until now, this library has only been used for bouncing purposes. The Watcher client is not intended for bouncing, so in what context do you want to use it? Is it to have a separate log processor or something?

Thanks

Translation:

The library is called php-lapi-client. I assumed it should provide a convenient interface for working with all CrowdSec LAPI methods. I need to send custom alerts from my application. I believe it’s better to extend the existing library rather than create a new one. If you think that AlertClient should not be part of this library, I can add it to another one.

WatcherClient purpose just covers /watcher/** API endpoints. In my opinion

@julienloizelet
Copy link
Collaborator

Hi @gam6itko

After discussing it with the internal team, I will examine the PR in more detail.

We think this could be an interesting feature to add, but we need to evaluate whether it would add too much maintenance overhead and ensure that it would not disrupt the functioning of other PHP libraries that depend on it.

Thanks again

@julienloizelet
Copy link
Collaborator

Hi @gam6itko

Just an update to inform you that I'm working on this (when I can).

For now, I have created a new branch from yours in order to fix some errors (unit tests, etc.).

Will try to continue working on this asap.

Thanks

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants