Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,21 @@ The present file will list all changes made to the project; according to the
### Added
- Some missing `readOnly` flags for properties for some schemas in High-Level API.
- Some missing UUID and color pattern constraints for properties in some schemas in High-Level API.
- High-Level API endpoints for configuration settings `/Setup/Config/{context}/{name}`.
- `uuid`, `user_tech`, `group_tech`, `date`, `date_creation`, `date_mod`, `planned_begin`, `planned_end`, `timeline_position`, `source_item_id`, and `source_of_item_id` properties for the applicable Ticket, Change and Problem Task schemas in the High-Level API v2.1.
- `date`, `timeline_position`, `source_item_id`, and `source_of_item_id` properties for the Followup schema in the High-Level API v2.1.
- `approver`, `approval_followup`, `date_creation`, `date_mod`, and `date_approval` properties for the Solution schema in the High-Level API v2.1.
- `timeline_position` property for the TicketValidation, ChangeValidation and Document_Item schemas in the High-Level API v2.1.
- `date_solve`, `date_close`, and `global_validation` properties for the applicable Ticket, Change and Problem schemas in the High-Level API v2.1.
- New schemas/endpoints for Reminders, RSS Feeds, and Reservations in the High-Level API v2.1.
- `date_password_change`, `location`, `authtype`, `last_login`, `default_profile` and `default_entity` properties for the User schema in the High-Level API v2.1.
- New UserPreferences schema and endpoints in the High-Level API v2.1.
- Some missing `completename` and `level` properties for some schemas in High-Level API v2.1.

### Changed
- Fixed `id` property in dropdown/linked object properties in schemas in High-Level API showing as readOnly when they are writable.
- Added High-Level API version 2.1. Make sure you are pinning your requests to a specific version (Ex: `/api.php/v2.0`) if needed to exclude endpoints/properties added in later versions. See version pinning in the getting started documentation `/api.php/getting-started`.
- High-Level API responses for not found routes now correctly return a body including the standard error properties (status, title, detail). This is not controlled by the API version.

### Deprecated

Expand Down
427 changes: 426 additions & 1 deletion src/Glpi/Api/HL/Controller/AdministrationController.php

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions src/Glpi/Api/HL/Controller/AssetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,19 @@ class: User::class,
}
}

// Post v2 additions to general assets
$schemas['SoftwareLicense']['properties']['completename'] = [
'x-version-introduced' => '2.1.0',
'type' => Doc\Schema::TYPE_STRING,
'readOnly' => true,
];
$schemas['SoftwareLicense']['properties']['level'] = [
'x-version-introduced' => '2.1.0',
'type' => Doc\Schema::TYPE_INTEGER,
'readOnly' => true,
];

// Additional asset schemas
$schemas['Cartridge'] = [
'x-version-introduced' => '2.0',
'x-itemtype' => Cartridge::class,
Expand Down
7 changes: 4 additions & 3 deletions src/Glpi/Api/HL/Controller/CoreController.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ public function showDocumentation(Request $request): Response
$swagger_content .= Html::script('/lib/swagger-ui.js');
$swagger_content .= Html::css('/lib/swagger-ui.css');
$favicon = Html::getPrefixedUrl('/pics/favicon.ico');
$doc_json_path = $CFG_GLPI['root_doc'] . '/api.php/doc.json';
$api_version = $this->getAPIVersion($request);
$doc_json_path = $CFG_GLPI['root_doc'] . '/api.php/v' . $api_version . '/doc.json';
$swagger_content .= <<<HTML
<link rel="shortcut icon" type="images/x-icon" href="$favicon" />
</head>
Expand Down Expand Up @@ -285,7 +286,7 @@ private function getAllowedMethodsForMatchedRoute(Request $request): array
)]
public function defaultRoute(Request $request): Response
{
return new JSONResponse(null, 404);
return self::getNotFoundErrorResponse();
}

#[Route(path: '/{req}', methods: ['OPTIONS'], requirements: ['req' => '.*'], priority: -1, security_level: Route::SECURITY_NONE)]
Expand All @@ -299,7 +300,7 @@ public function defaultOptionsRoute(Request $request): Response
$authenticated = Session::getLoginUserID() !== false;
$allowed_methods = $authenticated ? $this->getAllowedMethodsForMatchedRoute($request) : ['GET', 'POST', 'PATCH', 'PUT', "DELETE"];
if (count($allowed_methods) === 0) {
return new JSONResponse(null, 404);
return self::getNotFoundErrorResponse();
}
$response_headers = [];
if ($authenticated) {
Expand Down
296 changes: 296 additions & 0 deletions src/Glpi/Api/HL/Controller/ITILController.php

Large diffs are not rendered by default.

39 changes: 39 additions & 0 deletions src/Glpi/Api/HL/Controller/ManagementController.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
use BusinessCriticity;
use Cluster;
use CommonDBTM;
use CommonITILObject;
use Contact;
use Contract;
use Database;
Expand Down Expand Up @@ -370,9 +371,47 @@ protected static function getRawKnownSchemas(): array
'x-mapped-from' => 'documents_id',
'x-mapper' => static fn($v) => $CFG_GLPI["root_doc"] . "/front/document.send.php?docid=" . $v,
],
'timeline_position' => [
'x-version-introduced' => '2.1.0',
'type' => Doc\Schema::TYPE_NUMBER,
'enum' => [
CommonITILObject::NO_TIMELINE,
CommonITILObject::TIMELINE_NOTSET,
CommonITILObject::TIMELINE_LEFT,
CommonITILObject::TIMELINE_MIDLEFT,
CommonITILObject::TIMELINE_MIDRIGHT,
CommonITILObject::TIMELINE_RIGHT,
],
'description' => <<<EOT
The position in the timeline.
- 0: No timeline
- 1: Not set
- 2: Left
- 3: Mid left
- 4: Mid right
- 5: Right
EOT,
],
],
];

// Post v2 additions
$schemas['License']['properties']['is_recursive'] = [
'x-version-introduced' => '2.1.0',
'type' => Doc\Schema::TYPE_BOOLEAN,
'readOnly' => true,
];
$schemas['License']['properties']['completename'] = [
'x-version-introduced' => '2.1.0',
'type' => Doc\Schema::TYPE_STRING,
'readOnly' => true,
];
$schemas['License']['properties']['level'] = [
'x-version-introduced' => '2.1.0',
'type' => Doc\Schema::TYPE_INTEGER,
'readOnly' => true,
];

$schemas['Infocom'] = [
'x-version-introduced' => '2.0',
'type' => Doc\Schema::TYPE_OBJECT,
Expand Down
Loading
Loading