Skip to content

Commit 3abae4d

Browse files
cconard96cedric-anne
authored andcommitted
hlapi add some missing timeline properties
1 parent dc8112c commit 3abae4d

File tree

3 files changed

+210
-0
lines changed

3 files changed

+210
-0
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ The present file will list all changes made to the project; according to the
66
## [11.0.2] unreleased
77

88
### Added
9+
- `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.
10+
- `date`, `timeline_position`, `source_item_id`, and `source_of_item_id` properties for the Followup schema in the High-Level API v2.1.
11+
- `approver`, `approval_followup`, `date_creation`, `date_mod`, and `date_approval` properties for the Solution schema in the High-Level API v2.1.
12+
- `timeline_position` property for the TicketValidation, ChangeValidation and Document_Item schemas in the High-Level API v2.1.
13+
- `date_solve`, `date_close`, and `global_validation` properties for the applicable Ticket, Change and Problem schemas in the High-Level API v2.1.
914

1015
### Changed
1116
- 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`.

src/Glpi/Api/HL/Controller/ITILController.php

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ public static function getRawKnownSchemas(): array
178178
],
179179
'name' => ['type' => Doc\Schema::TYPE_STRING],
180180
'content' => ['type' => Doc\Schema::TYPE_STRING],
181+
'user_recipient' => self::getDropdownTypeSchema(class: User::class, field: 'users_id_recipient', full_schema: 'User') + ['x-version-introduced' => '2.1.0'],
182+
'user_editor' => self::getDropdownTypeSchema(class: User::class, field: 'users_id_lastupdater', full_schema: 'User') + ['x-version-introduced' => '2.1.0'],
181183
'is_deleted' => ['type' => Doc\Schema::TYPE_BOOLEAN],
182184
'category' => self::getDropdownTypeSchema(class: ITILCategory::class, full_schema: 'ITILCategory'),
183185
'location' => self::getDropdownTypeSchema(class: Location::class, full_schema: 'Location'),
@@ -203,6 +205,18 @@ public static function getRawKnownSchemas(): array
203205
'date_creation' => ['type' => Doc\Schema::TYPE_STRING, 'format' => Doc\Schema::FORMAT_STRING_DATE_TIME],
204206
'date_mod' => ['type' => Doc\Schema::TYPE_STRING, 'format' => Doc\Schema::FORMAT_STRING_DATE_TIME],
205207
'date' => ['type' => Doc\Schema::TYPE_STRING, 'format' => Doc\Schema::FORMAT_STRING_DATE_TIME],
208+
'date_solve' => [
209+
'x-version-introduced' => '2.1.0',
210+
'type' => Doc\Schema::TYPE_STRING,
211+
'format' => Doc\Schema::FORMAT_STRING_DATE_TIME,
212+
'x-field' => 'solvedate',
213+
],
214+
'date_close' => [
215+
'x-version-introduced' => '2.1.0',
216+
'type' => Doc\Schema::TYPE_STRING,
217+
'format' => Doc\Schema::FORMAT_STRING_DATE_TIME,
218+
'x-field' => 'closedate',
219+
],
206220
],
207221
];
208222

@@ -375,6 +389,25 @@ public static function getRawKnownSchemas(): array
375389
];
376390
$schemas[$itil_type]['properties']['request_type'] = self::getDropdownTypeSchema(class: RequestType::class, full_schema: 'RequestType');
377391
}
392+
if ($itil_type === Ticket::class || $itil_type === Change::class) {
393+
$schemas[$itil_type]['properties']['global_validation'] = [
394+
'x-version-introduced' => '2.1.0',
395+
'type' => Doc\Schema::TYPE_INTEGER,
396+
'enum' => [
397+
CommonITILValidation::NONE,
398+
CommonITILValidation::WAITING,
399+
CommonITILValidation::ACCEPTED,
400+
CommonITILValidation::REFUSED,
401+
],
402+
'description' => <<<EOT
403+
The global status of the validation.
404+
- 1: None
405+
- 2: Waiting
406+
- 3: Accepted
407+
- 4: Refused
408+
EOT,
409+
];
410+
}
378411
$schemas[$itil_type]['x-itemtype'] = $itil_type;
379412
$status_description = '';
380413
foreach ($itil_type::getAllStatusArray() as $status => $status_name) {
@@ -421,6 +454,24 @@ public static function getRawKnownSchemas(): array
421454
];
422455
}
423456

457+
$timeline_position_enum = [
458+
CommonITILObject::NO_TIMELINE,
459+
CommonITILObject::TIMELINE_NOTSET,
460+
CommonITILObject::TIMELINE_LEFT,
461+
CommonITILObject::TIMELINE_MIDLEFT,
462+
CommonITILObject::TIMELINE_MIDRIGHT,
463+
CommonITILObject::TIMELINE_RIGHT,
464+
];
465+
$timeline_position_description = <<<EOT
466+
The position in the timeline.
467+
- 0: No timeline
468+
- 1: Not set
469+
- 2: Left
470+
- 3: Mid left
471+
- 4: Mid right
472+
- 5: Right
473+
EOT;
474+
424475
$base_task_schema = [
425476
'type' => Doc\Schema::TYPE_OBJECT,
426477
'x-rights-conditions' => [ // Object-level extra permissions
@@ -444,11 +495,46 @@ public static function getRawKnownSchemas(): array
444495
'format' => Doc\Schema::FORMAT_INTEGER_INT64,
445496
'readOnly' => true,
446497
],
498+
'uuid' => [
499+
'x-version-introduced' => '2.1.0',
500+
'type' => Doc\Schema::TYPE_STRING,
501+
'format' => Doc\Schema::PATTERN_UUIDV4,
502+
'readOnly' => true,
503+
],
447504
'content' => ['type' => Doc\Schema::TYPE_STRING],
448505
'is_private' => ['type' => Doc\Schema::TYPE_BOOLEAN],
449506
'user' => self::getDropdownTypeSchema(class: User::class, full_schema: 'User'),
450507
'user_editor' => self::getDropdownTypeSchema(class: User::class, field: 'users_id_editor', full_schema: 'User'),
508+
'user_tech' => self::getDropdownTypeSchema(class: User::class, field: 'users_id_tech', full_schema: 'User') + ['x-version-introduced' => '2.1.0'],
509+
'group_tech' => self::getDropdownTypeSchema(class: Group::class, field: 'groups_id_tech', full_schema: 'Group') + ['x-version-introduced' => '2.1.0'],
510+
'date' => [
511+
'x-version-introduced' => '2.1.0',
512+
'type' => Doc\Schema::TYPE_STRING,
513+
'format' => Doc\Schema::FORMAT_STRING_DATE_TIME,
514+
],
515+
'date_creation' => [
516+
'x-version-introduced' => '2.1.0',
517+
'type' => Doc\Schema::TYPE_STRING,
518+
'format' => Doc\Schema::FORMAT_STRING_DATE_TIME,
519+
],
520+
'date_mod' => [
521+
'x-version-introduced' => '2.1.0',
522+
'type' => Doc\Schema::TYPE_STRING,
523+
'format' => Doc\Schema::FORMAT_STRING_DATE_TIME,
524+
],
451525
'duration' => ['type' => Doc\Schema::TYPE_INTEGER, 'x-field' => 'actiontime'],
526+
'planned_begin' => [
527+
'x-version-introduced' => '2.1.0',
528+
'type' => Doc\Schema::TYPE_STRING,
529+
'format' => Doc\Schema::FORMAT_STRING_DATE_TIME,
530+
'x-field' => 'begin',
531+
],
532+
'planned_end' => [
533+
'x-version-introduced' => '2.1.0',
534+
'type' => Doc\Schema::TYPE_STRING,
535+
'format' => Doc\Schema::FORMAT_STRING_DATE_TIME,
536+
'x-field' => 'end',
537+
],
452538
'state' => [
453539
'type' => Doc\Schema::TYPE_INTEGER,
454540
'enum' => [
@@ -464,13 +550,31 @@ public static function getRawKnownSchemas(): array
464550
EOT,
465551
],
466552
'category' => self::getDropdownTypeSchema(class: TaskCategory::class, full_schema: 'TaskCategory'),
553+
'timeline_position' => [
554+
'x-version-introduced' => '2.1.0',
555+
'type' => Doc\Schema::TYPE_NUMBER,
556+
'enum' => $timeline_position_enum,
557+
'description' => $timeline_position_description,
558+
],
467559
],
468560
];
469561

470562
$schemas['TicketTask'] = $base_task_schema;
471563
$schemas['TicketTask']['x-version-introduced'] = '2.0';
472564
$schemas['TicketTask']['x-itemtype'] = TicketTask::class;
473565
$schemas['TicketTask']['properties'][Ticket::getForeignKeyField()] = ['type' => Doc\Schema::TYPE_INTEGER, 'format' => Doc\Schema::FORMAT_INTEGER_INT64];
566+
$schemas['TicketTask']['properties']['source_item_id'] = [
567+
'x-version-introduced' => '2.1.0',
568+
'type' => Doc\Schema::TYPE_INTEGER,
569+
'format' => Doc\Schema::FORMAT_INTEGER_INT64,
570+
'x-field' => 'sourceitems_id',
571+
];
572+
$schemas['TicketTask']['properties']['source_of_item_id'] = [
573+
'x-version-introduced' => '2.1.0',
574+
'type' => Doc\Schema::TYPE_INTEGER,
575+
'format' => Doc\Schema::FORMAT_INTEGER_INT64,
576+
'x-field' => 'sourceof_items_id',
577+
];
474578

475579
$schemas['ChangeTask'] = $base_task_schema;
476580
$schemas['ChangeTask']['x-version-introduced'] = '2.0';
@@ -559,8 +663,31 @@ public static function getRawKnownSchemas(): array
559663
'user' => self::getDropdownTypeSchema(class: User::class, full_schema: 'User'),
560664
'user_editor' => self::getDropdownTypeSchema(class: User::class, field: 'users_id_editor', full_schema: 'User'),
561665
'request_type' => self::getDropdownTypeSchema(RequestType::class, full_schema: 'RequestType'),
666+
'date' => [
667+
'x-version-introduced' => '2.1.0',
668+
'type' => Doc\Schema::TYPE_STRING,
669+
'format' => Doc\Schema::FORMAT_STRING_DATE_TIME,
670+
],
562671
'date_creation' => ['type' => Doc\Schema::TYPE_STRING, 'format' => Doc\Schema::FORMAT_STRING_DATE_TIME],
563672
'date_mod' => ['type' => Doc\Schema::TYPE_STRING, 'format' => Doc\Schema::FORMAT_STRING_DATE_TIME],
673+
'timeline_position' => [
674+
'x-version-introduced' => '2.1.0',
675+
'type' => Doc\Schema::TYPE_NUMBER,
676+
'enum' => $timeline_position_enum,
677+
'description' => $timeline_position_description,
678+
],
679+
'source_item_id' => [
680+
'x-version-introduced' => '2.1.0',
681+
'type' => Doc\Schema::TYPE_INTEGER,
682+
'format' => Doc\Schema::FORMAT_INTEGER_INT64,
683+
'x-field' => 'sourceitems_id',
684+
],
685+
'source_of_item_id' => [
686+
'x-version-introduced' => '2.1.0',
687+
'type' => Doc\Schema::TYPE_INTEGER,
688+
'format' => Doc\Schema::FORMAT_INTEGER_INT64,
689+
'x-field' => 'sourceof_items_id',
690+
],
564691
],
565692
];
566693

@@ -579,6 +706,56 @@ public static function getRawKnownSchemas(): array
579706
'content' => ['type' => Doc\Schema::TYPE_STRING],
580707
'user' => self::getDropdownTypeSchema(class: User::class, full_schema: 'User'),
581708
'user_editor' => self::getDropdownTypeSchema(class: User::class, field: 'users_id_editor', full_schema: 'User'),
709+
'approver' => self::getDropdownTypeSchema(class: User::class, field: 'users_id_approval', full_schema: 'User') + ['x-version-introduced' => '2.1.0'],
710+
'status' => [
711+
'type' => Doc\Schema::TYPE_INTEGER,
712+
'enum' => [
713+
CommonITILValidation::NONE,
714+
CommonITILValidation::WAITING,
715+
CommonITILValidation::ACCEPTED,
716+
CommonITILValidation::REFUSED,
717+
],
718+
'description' => <<<EOT
719+
The status of the solution.
720+
- 1: None
721+
- 2: Waiting
722+
- 3: Accepted
723+
- 4: Refused
724+
EOT,
725+
],
726+
'approval_followup' => [
727+
'x-version-introduced' => '2.1.0',
728+
'type' => Doc\Schema::TYPE_OBJECT,
729+
'x-field' => ITILFollowup::getForeignKeyField(),
730+
'x-itemtype' => ITILFollowup::class,
731+
'x-join' => [
732+
'table' => ITILFollowup::getTable(),
733+
'fkey' => ITILFollowup::getForeignKeyField(),
734+
'field' => 'id',
735+
],
736+
'properties' => [
737+
'id' => [
738+
'type' => Doc\Schema::TYPE_INTEGER,
739+
'format' => Doc\Schema::FORMAT_INTEGER_INT64,
740+
'readOnly' => true,
741+
],
742+
],
743+
],
744+
'date_creation' => [
745+
'x-version-introduced' => '2.1.0',
746+
'type' => Doc\Schema::TYPE_STRING,
747+
'format' => Doc\Schema::FORMAT_STRING_DATE_TIME,
748+
],
749+
'date_mod' => [
750+
'x-version-introduced' => '2.1.0',
751+
'type' => Doc\Schema::TYPE_STRING,
752+
'format' => Doc\Schema::FORMAT_STRING_DATE_TIME,
753+
],
754+
'date_approval' => [
755+
'x-version-introduced' => '2.1.0',
756+
'type' => Doc\Schema::TYPE_STRING,
757+
'format' => Doc\Schema::FORMAT_STRING_DATE_TIME,
758+
],
582759
],
583760
];
584761

@@ -625,6 +802,12 @@ public static function getRawKnownSchemas(): array
625802
],
626803
'submission_date' => ['type' => Doc\Schema::TYPE_STRING, 'format' => Doc\Schema::FORMAT_STRING_DATE_TIME],
627804
'approval_date' => ['type' => Doc\Schema::TYPE_STRING, 'format' => Doc\Schema::FORMAT_STRING_DATE_TIME, 'x-field' => 'validation_date'],
805+
'timeline_position' => [
806+
'x-version-introduced' => '2.1.0',
807+
'type' => Doc\Schema::TYPE_NUMBER,
808+
'enum' => $timeline_position_enum,
809+
'description' => $timeline_position_description,
810+
],
628811
],
629812
];
630813

src/Glpi/Api/HL/Controller/ManagementController.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
use BusinessCriticity;
4141
use Cluster;
4242
use CommonDBTM;
43+
use CommonITILObject;
4344
use Contact;
4445
use Contract;
4546
use Database;
@@ -366,6 +367,27 @@ protected static function getRawKnownSchemas(): array
366367
'x-mapped-from' => 'documents_id',
367368
'x-mapper' => static fn($v) => $CFG_GLPI["root_doc"] . "/front/document.send.php?docid=" . $v,
368369
],
370+
'timeline_position' => [
371+
'x-version-introduced' => '2.1.0',
372+
'type' => Doc\Schema::TYPE_NUMBER,
373+
'enum' => [
374+
CommonITILObject::NO_TIMELINE,
375+
CommonITILObject::TIMELINE_NOTSET,
376+
CommonITILObject::TIMELINE_LEFT,
377+
CommonITILObject::TIMELINE_MIDLEFT,
378+
CommonITILObject::TIMELINE_MIDRIGHT,
379+
CommonITILObject::TIMELINE_RIGHT,
380+
],
381+
'description' => <<<EOT
382+
The position in the timeline.
383+
- 0: No timeline
384+
- 1: Not set
385+
- 2: Left
386+
- 3: Mid left
387+
- 4: Mid right
388+
- 5: Right
389+
EOT,
390+
],
369391
],
370392
];
371393

0 commit comments

Comments
 (0)