Skip to content

Commit

Permalink
Merge pull request #10 from julienloizelet/feat/v3-capi
Browse files Browse the repository at this point in the history
Feat/v3 capi
  • Loading branch information
julienloizelet committed Mar 9, 2023
2 parents ecf9afe + ce8dabb commit 86e85c2
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 14 deletions.
17 changes: 13 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,23 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## Public API
## SemVer public API

The purpose of this section is to declare the public API of this library as required by [item 1 of semantic versioning specification](https://semver.org/spec/v2.0.0.html#spec-item-1).

The public API of this library consists of all public or protected methods, properties and constants belonging to the `src` folder.
The [public API](https://semver.org/spec/v2.0.0.html#spec-item-1) of this library consists of all public or protected methods, properties and constants belonging to the `src` folder.

---

## [3.0.0](https://github.com/crowdsecurity/php-lapi-client/releases/tag/v3.0.0) - 2023-03-09
[_Compare with previous release_](https://github.com/crowdsecurity/php-lapi-client/compare/v2.0.0...v3.0.0)

### Changed


- *Breaking change*: Use `crowdsec/common` `^2.0.0` dependency instead of `^1.2.0`
- *Breaking change*: If not null, the second param of `Bouncer` constructor must implement `RequestHandlerInterface`


---

## [2.0.0](https://github.com/crowdsecurity/php-lapi-client/releases/tag/v2.0.0) - 2023-02-02
[_Compare with previous release_](https://github.com/crowdsecurity/php-lapi-client/compare/v1.0.1...v2.0.0)
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
},
"require": {
"php": "^7.2.5 || ^8.0",
"crowdsec/common": "^1.2.0",
"crowdsec/common": "^2.0.0",
"ext-json": "*",
"symfony/config": "^4.4.44 || ^5.4.11 || ^6.0.11",
"monolog/monolog": "^1.17 || ^2.1"
Expand Down
8 changes: 4 additions & 4 deletions docs/USER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -311,17 +311,17 @@ By default, the `Bouncer` object will do curl requests to call the LAPI. If for
use curl then you can create your own request handler class and pass it as a second parameter of the `Bouncer`
constructor.

Your custom request handler class must extend the `AbstractRequestHandler` class of the `crowdsec/common` dependency,
and you will have to explicitly write an `handle` method:
Your custom request handler class must implement the `RequestHandlerInterface` interface of the `crowdsec/common`
dependency, and you will have to explicitly write an `handle` method:

```php
<?php

use CrowdSec\Common\Client\HttpMessage\Request;
use CrowdSec\Common\Client\HttpMessage\Response;
use CrowdSec\Common\Client\RequestHandler\AbstractRequestHandler;
use CrowdSec\Common\Client\RequestHandler\RequestHandlerInterface;

class CustomRequestHandler extends AbstractRequestHandler
class CustomRequestHandler implements RequestHandlerInterface
{
/**
* Performs an HTTP request and returns a response.
Expand Down
4 changes: 2 additions & 2 deletions src/Bouncer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use CrowdSec\Common\Client\AbstractClient;
use CrowdSec\Common\Client\ClientException as CommonClientException;
use CrowdSec\Common\Client\RequestHandler\AbstractRequestHandler;
use CrowdSec\Common\Client\RequestHandler\RequestHandlerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\Config\Definition\Processor;

Expand All @@ -33,7 +33,7 @@ class Bouncer extends AbstractClient

public function __construct(
array $configs,
AbstractRequestHandler $requestHandler = null,
RequestHandlerInterface $requestHandler = null,
LoggerInterface $logger = null
) {
$this->configure($configs);
Expand Down
2 changes: 1 addition & 1 deletion src/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ class Constants extends CommonConstants
/**
* @var string The current version of this library
*/
public const VERSION = 'v2.0.0';
public const VERSION = 'v3.0.0';
}
2 changes: 1 addition & 1 deletion tests/scripts/bouncer/decisions-filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

require_once __DIR__ . '/../../../vendor/autoload.php';

use CrowdSec\LapiClient\Bouncer;
use CrowdSec\Common\Logger\ConsoleLog;
use CrowdSec\LapiClient\Bouncer;

$filter = isset($argv[1]) ? json_decode($argv[1], true) : [];
$bouncerKey = $argv[2] ?? false;
Expand Down
2 changes: 1 addition & 1 deletion tests/scripts/bouncer/decisions-stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

require_once __DIR__ . '/../../../vendor/autoload.php';

use CrowdSec\Common\Logger\ConsoleLog;
use CrowdSec\LapiClient\Bouncer;
use CrowdSec\LapiClient\Constants;
use CrowdSec\Common\Logger\ConsoleLog;

$startup = isset($argv[1]) ? (bool) $argv[1] : false;
$filter = isset($argv[2]) ? json_decode($argv[2], true)
Expand Down

0 comments on commit 86e85c2

Please sign in to comment.