No description
Find a file
Jérémy Munsch a7dce9544b
docs: update regeneration instructions for Kiota client
Clarified the use of the official Microsoft Kiota container
and added incremental update instructions.
2026-10-06 16:39:00 +02:00
client feat(health): add Oracle health check endpoint and models 2026-10-06 16:38:38 +02:00
documentation feat(health): add Oracle health check endpoint and models 2026-10-06 16:38:38 +02:00
.gitattributes chore(meta): add MIT LICENSE and .gitattributes export-ignore rules 2026-09-16 12:25:06 +02:00
.gitignore chore: ignore log files 2026-09-18 12:21:03 +02:00
.gitlab-ci.yml ci: update CI configuration for Composer package publishing 2026-09-16 12:24:58 +02:00
composer.json build(composer): add PHP 8.2+ constraint and configure allow-plugins 2026-09-16 12:25:06 +02:00
LICENSE chore(meta): add MIT LICENSE and .gitattributes export-ignore rules 2026-09-16 12:25:06 +02:00
README.md docs: update regeneration instructions for Kiota client 2026-10-06 16:39:00 +02:00

Arcadia API Kiota Client

Package PHP fournissant le client d'API fortement typé pour l'API Arcadia, généré automatiquement à l'aide de Microsoft Kiota à partir de la spécification OpenAPI 3.0.

Ce package constitue la couche d'infrastructure bas niveau utilisée notamment par le client de haut niveau uwil/arcadia-api-php-client.


Prérequis

  • PHP : ^8.2 || ^8.3 || ^8.4 || ^8.5
  • Extensions PHP : curl, json, mbstring
  • Client HTTP PSR-18 / Guzzle : requis pour exécuter les requêtes (ex: guzzlehttp/guzzle: ^7.0)

Installation

Via Composer

composer require uwil/arcadia-kiota-open-api-client

Configuration avec le registre GitLab (paquet privé)

Si le paquet est distribué via le registre Composer de GitLab, ajoutez le dépôt dans votre composer.json :

{
  "repositories": [
      {
          "type": "composer",
          "url": "https://lab.s-web.fr/api/v4/group/23/-/packages/composer/packages.json"
      }
  ]
}

Et configurez votre jeton d'accès dans ~/.composer/auth.json ou via la variable d'environnement :

composer config gitlab-token.lab.s-web.fr <VOTRE_TOKEN_GITLAB>

Démarrage rapide

Kiota découple la logique de requêtage du moteur HTTP via un RequestAdapter. Voici comment initialiser et utiliser le client avec Guzzle :

use GuzzleHttp\Client as GuzzleHttpClient;
use Microsoft\Kiota\Abstractions\Authentication\AnonymousAuthenticationProvider;
use Microsoft\Kiota\Http\GuzzleRequestAdapter;
use Uwil\ArcadiaKiotaOpenApiClient\ApiClient;

// 1. Configuration du client HTTP de transport
$guzzle = new GuzzleHttpClient([
    'base_uri' => 'https://api.arcadia.example.com',
    'timeout'  => 10.0,
]);

// 2. Création de l'adaptateur de requêtes Kiota
// Note : Si l'API requiert une signature ou des en-têtes d'authentification personnalisés,
// ils peuvent être injectés via des middlewares Guzzle ou un AuthenticationProvider dédié.
$authProvider   = new AnonymousAuthenticationProvider();
$requestAdapter = new GuzzleRequestAdapter($authProvider, $guzzle);
$requestAdapter->setBaseUrl('https://api.arcadia.example.com');

// 3. Instanciation du client d'API généré
$client = new ApiClient($requestAdapter);

// 4. Exemples d'appels d'API (appels asynchrones retournant une Promise)
// Récupérer la liste des marques
$brandList = $client->brands()->get()->wait();
foreach ($brandList->getBrands() as $brand) {
    echo $brand->getCode() . ' - ' . $brand->getLabel() . PHP_EOL;
}

// Récupérer une fiche INCO par son identifiant
$incoItem = $client->incoSheets()->byIncoId('100')->get()->wait();
echo $incoItem->getName() . PHP_EOL;

// Récupérer la composition nutritionnelle d'une fiche INCO
$compoItem = $client->incoSheets()->byIncoId('100')->composition()->get()->wait();
echo 'Énergie kcal : ' . $compoItem->getEnergy()?->getReference()?->getEnergyKcal() . PHP_EOL;

Endpoints couverts

Ressource Méthode Kiota Endpoint HTTP
Brands $client->brands()->get() GET /brands
Brand (Item) $client->brands()->byBrandCode('...')->get() GET /brands/{brandCode}
Employees $client->employees()->get() GET /employees
Employee (Item) $client->employees()->byEmployeeId('...')->get() GET /employees/{employeeId}
Inco Sheets $client->incoSheets()->get() GET /inco-sheets
Inco Sheet (Item) $client->incoSheets()->byIncoId('...')->get() GET /inco-sheets/{incoId}
Inco Search $client->incoSheets()->search()->get() GET /inco-sheets/search
Composition $client->incoSheets()->byIncoId('...')->composition()->get() GET /inco-sheets/{incoId}/composition
Health Check $client->health()->get() GET /health

Régénération du client Kiota (pour les contributeurs)

Lorsque la spécification documentation/openapi.yaml évolue, regénérez le client avec le conteneur officiel Microsoft Kiota :

Avec Docker ou Podman

cd arcadia-kiota-openapi-client

# Option 1 : Régénération complète à partir du fichier OpenAPI
docker run --rm \
  --user 0:0 \
  -v "${PWD}":/workspace:Z \
  [mcr.microsoft.com/openapi/kiota](https://mcr.microsoft.com/openapi/kiota) generate \
  --language php \
  -n Uwil\\ArcadiaKiotaOpenApiClient \
  --output /workspace/client \
  --openapi /workspace/documentation/openapi.yaml \
  --clean-output \
  --type-access-modifier Private

# Option 2 : Mise à jour incrémentale basée sur le kiota-lock.json existant
docker run --rm \
  --user 0:0 \
  -v "${PWD}":/workspace:Z \
  [mcr.microsoft.com/openapi/kiota](https://mcr.microsoft.com/openapi/kiota) update \
  --output /workspace/client \
  --clean-output

Publication et CI/CD

Le déploiement est automatisé via .gitlab-ci.yml. La publication sur le registre Composer GitLab se déclenche à la création d'un tag Git sémantique :

git tag 1.0.0
git push origin 1.0.0

Le pipeline CI exécute alors le job publish qui enregistre automatiquement la nouvelle version du package.


Licence

Ce projet est sous licence MIT. Voir le fichier LICENCE.md pour plus de détails.