Skip to content

Commit b142b13

Browse files
authored
hlapi add slm features
1 parent 69d7151 commit b142b13

File tree

2 files changed

+216
-0
lines changed

2 files changed

+216
-0
lines changed

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

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@
6262
use ITILFollowup;
6363
use ITILSolution;
6464
use Location;
65+
use OLA;
66+
use OlaLevel;
6567
use Planning;
6668
use PlanningEventCategory;
6769
use PlanningExternalEvent;
@@ -71,6 +73,8 @@
7173
use RecurrentChange;
7274
use RequestType;
7375
use Session;
76+
use SLA;
77+
use SlaLevel;
7478
use TaskCategory;
7579
use Ticket;
7680
use TicketRecurrent;
@@ -202,6 +206,39 @@ public static function getRawKnownSchemas(): array
202206
'type' => Doc\Schema::TYPE_INTEGER,
203207
'readOnly' => true,
204208
],
209+
'begin_waiting_date' => [
210+
'x-version-introduced' => '2.1.0',
211+
'type' => Doc\Schema::TYPE_STRING,
212+
'readOnly' => true,
213+
'format' => Doc\Schema::FORMAT_STRING_DATE_TIME,
214+
],
215+
'waiting_duration' => [
216+
'x-version-introduced' => '2.1.0',
217+
'type' => Doc\Schema::TYPE_INTEGER,
218+
'readOnly' => true,
219+
'description' => 'Total waiting duration in seconds',
220+
],
221+
'resolution_duration' => [
222+
'x-version-introduced' => '2.1.0',
223+
'type' => Doc\Schema::TYPE_INTEGER,
224+
'readOnly' => true,
225+
'x-field' => 'solve_delay_stat',
226+
'description' => 'Total resolution duration in seconds',
227+
],
228+
'close_duration' => [
229+
'x-version-introduced' => '2.1.0',
230+
'type' => Doc\Schema::TYPE_INTEGER,
231+
'readOnly' => true,
232+
'x-field' => 'close_delay_stat',
233+
'description' => 'Total close duration in seconds',
234+
],
235+
'resolution_date' => [
236+
'x-version-introduced' => '2.1.0',
237+
'type' => Doc\Schema::TYPE_STRING,
238+
'format' => Doc\Schema::FORMAT_STRING_DATE_TIME,
239+
'readOnly' => true,
240+
'x-field' => 'time_to_resolve',
241+
],
205242
'date_creation' => ['type' => Doc\Schema::TYPE_STRING, 'format' => Doc\Schema::FORMAT_STRING_DATE_TIME],
206243
'date_mod' => ['type' => Doc\Schema::TYPE_STRING, 'format' => Doc\Schema::FORMAT_STRING_DATE_TIME],
207244
'date' => ['type' => Doc\Schema::TYPE_STRING, 'format' => Doc\Schema::FORMAT_STRING_DATE_TIME],
@@ -388,6 +425,66 @@ public static function getRawKnownSchemas(): array
388425
'type' => Doc\Schema::TYPE_STRING,
389426
];
390427
$schemas[$itil_type]['properties']['request_type'] = self::getDropdownTypeSchema(class: RequestType::class, full_schema: 'RequestType');
428+
429+
// SLA/OLA Properties
430+
$schemas[$itil_type]['properties']['take_into_account_date'] = [
431+
'x-version-introduced' => '2.1.0',
432+
'type' => Doc\Schema::TYPE_STRING,
433+
'format' => Doc\Schema::FORMAT_STRING_DATE_TIME,
434+
'readOnly' => true,
435+
'x-field' => 'takeintoaccountdate',
436+
];
437+
$schemas[$itil_type]['properties']['take_into_account_duration'] = [
438+
'x-version-introduced' => '2.1.0',
439+
'type' => Doc\Schema::TYPE_INTEGER,
440+
'readOnly' => true,
441+
'description' => 'Total take into account duration in seconds',
442+
'x-field' => 'takeintoaccount_delay_stat',
443+
];
444+
$schemas[$itil_type]['properties']['sla_ttr'] = self::getDropdownTypeSchema(class: SLA::class, field: 'slas_id_ttr', full_schema: 'SLA') + ['x-version-introduced' => '2.1.0'];
445+
$schemas[$itil_type]['properties']['sla_tto'] = self::getDropdownTypeSchema(class: SLA::class, field: 'slas_id_tto', full_schema: 'SLA') + ['x-version-introduced' => '2.1.0'];
446+
$schemas[$itil_type]['properties']['ola_ttr'] = self::getDropdownTypeSchema(class: OLA::class, field: 'olas_id_ttr', full_schema: 'OLA') + ['x-version-introduced' => '2.1.0'];
447+
$schemas[$itil_type]['properties']['ola_tto'] = self::getDropdownTypeSchema(class: OLA::class, field: 'olas_id_tto', full_schema: 'OLA') + ['x-version-introduced' => '2.1.0'];
448+
$schemas[$itil_type]['properties']['sla_level_ttr'] = self::getDropdownTypeSchema(class: SlaLevel::class, field: 'slalevels_id_ttr', full_schema: 'SLALevel') + ['x-version-introduced' => '2.1.0'];
449+
$schemas[$itil_type]['properties']['ola_level_ttr'] = self::getDropdownTypeSchema(class: OlaLevel::class, field: 'olalevels_id_ttr', full_schema: 'OLALevel') + ['x-version-introduced' => '2.1.0'];
450+
$schemas[$itil_type]['properties']['sla_waiting_duration'] = [
451+
'x-version-introduced' => '2.1.0',
452+
'type' => Doc\Schema::TYPE_INTEGER,
453+
'readOnly' => true,
454+
'description' => 'Total SLA waiting duration in seconds',
455+
];
456+
$schemas[$itil_type]['properties']['ola_waiting_duration'] = [
457+
'x-version-introduced' => '2.1.0',
458+
'type' => Doc\Schema::TYPE_INTEGER,
459+
'readOnly' => true,
460+
'description' => 'Total OLA waiting duration in seconds',
461+
];
462+
$schemas[$itil_type]['properties']['ola_ttr_begin_date'] = [
463+
'x-version-introduced' => '2.1.0',
464+
'type' => Doc\Schema::TYPE_STRING,
465+
'readOnly' => true,
466+
'format' => Doc\Schema::FORMAT_STRING_DATE_TIME,
467+
];
468+
$schemas[$itil_type]['properties']['ola_tto_begin_date'] = [
469+
'x-version-introduced' => '2.1.0',
470+
'type' => Doc\Schema::TYPE_STRING,
471+
'readOnly' => true,
472+
'format' => Doc\Schema::FORMAT_STRING_DATE_TIME,
473+
];
474+
$schemas[$itil_type]['properties']['internal_resolution_date'] = [
475+
'x-version-introduced' => '2.1.0',
476+
'type' => Doc\Schema::TYPE_STRING,
477+
'format' => Doc\Schema::FORMAT_STRING_DATE_TIME,
478+
'readOnly' => true,
479+
'x-field' => 'internal_time_to_resolve',
480+
];
481+
$schemas[$itil_type]['properties']['internal_take_into_account_date'] = [
482+
'x-version-introduced' => '2.1.0',
483+
'type' => Doc\Schema::TYPE_STRING,
484+
'format' => Doc\Schema::FORMAT_STRING_DATE_TIME,
485+
'readOnly' => true,
486+
'x-field' => 'internal_time_to_own',
487+
];
391488
}
392489
if ($itil_type === Ticket::class || $itil_type === Change::class) {
393490
$schemas[$itil_type]['properties']['global_validation'] = [

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

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@
3636
namespace Glpi\Api\HL\Controller;
3737

3838
use AuthLDAP;
39+
use Calendar;
3940
use CommonDBTM;
4041
use Config;
42+
use Entity;
4143
use Glpi\Api\HL\Doc as Doc;
4244
use Glpi\Api\HL\Middleware\ResultFormatterMiddleware;
4345
use Glpi\Api\HL\ResourceAccessor;
@@ -46,6 +48,11 @@
4648
use Glpi\Http\JSONResponse;
4749
use Glpi\Http\Request;
4850
use Glpi\Http\Response;
51+
use OLA;
52+
use OlaLevel;
53+
use SLA;
54+
use SlaLevel;
55+
use SLM;
4956

5057
#[Route(path: '/Setup', tags: ['Setup'])]
5158
final class SetupController extends AbstractController
@@ -54,6 +61,70 @@ public static function getRawKnownSchemas(): array
5461
{
5562
global $DB;
5663

64+
$base_la_properties = [
65+
'id' => [
66+
'type' => Doc\Schema::TYPE_INTEGER,
67+
'format' => Doc\Schema::FORMAT_INTEGER_INT64,
68+
'readOnly' => true,
69+
],
70+
'name' => ['type' => Doc\Schema::TYPE_STRING],
71+
'slm' => self::getDropdownTypeSchema(class: SLM::class, full_schema: 'SLM'),
72+
'entity' => self::getDropdownTypeSchema(class: Entity::class, full_schema: 'Entity'),
73+
'is_recursive' => ['type' => Doc\Schema::TYPE_BOOLEAN],
74+
'type' => [
75+
'type' => Doc\Schema::TYPE_INTEGER,
76+
'enum' => [SLM::TTR, SLM::TTO],
77+
'description' => <<<EOT
78+
- 0: Time to resolve (TTR)
79+
- 1: Time to own (TTO)
80+
EOT,
81+
],
82+
'comment' => ['type' => Doc\Schema::TYPE_STRING],
83+
'time' => [
84+
'type' => Doc\Schema::TYPE_INTEGER,
85+
'x-field' => 'number_time',
86+
'description' => 'Time in the unit defined by the time_unit property',
87+
],
88+
'time_unit' => [
89+
'type' => Doc\Schema::TYPE_STRING,
90+
'enum' => ['minute', 'hour', 'day', 'month'],
91+
'description' => 'Unit of time for the time property',
92+
],
93+
'use_ticket_calendar' => ['type' => Doc\Schema::TYPE_BOOLEAN],
94+
'calendar' => self::getDropdownTypeSchema(class: Calendar::class, full_schema: 'Calendar'),
95+
'end_of_working_day' => [
96+
'type' => Doc\Schema::TYPE_BOOLEAN,
97+
'description' => 'Whether the time computation will target the end of the working day',
98+
],
99+
'date_creation' => ['type' => Doc\Schema::TYPE_STRING, 'format' => Doc\Schema::FORMAT_STRING_DATE_TIME],
100+
'date_mod' => ['type' => Doc\Schema::TYPE_STRING, 'format' => Doc\Schema::FORMAT_STRING_DATE_TIME],
101+
];
102+
103+
$base_la_level_properties = [
104+
'id' => [
105+
'type' => Doc\Schema::TYPE_INTEGER,
106+
'format' => Doc\Schema::FORMAT_INTEGER_INT64,
107+
'readOnly' => true,
108+
],
109+
'uuid' => [
110+
'type' => Doc\Schema::TYPE_STRING,
111+
'pattern' => Doc\Schema::PATTERN_UUIDV4,
112+
'readOnly' => true,
113+
],
114+
'name' => ['type' => Doc\Schema::TYPE_STRING],
115+
'entity' => self::getDropdownTypeSchema(class: Entity::class, full_schema: 'Entity'),
116+
'is_recursive' => ['type' => Doc\Schema::TYPE_BOOLEAN],
117+
'execution_time' => [
118+
'type' => Doc\Schema::TYPE_INTEGER,
119+
'readOnly' => true,
120+
],
121+
'operator' => [
122+
'type' => Doc\Schema::TYPE_STRING,
123+
'enum' => ['AND', 'OR'],
124+
'x-field' => 'match',
125+
],
126+
];
127+
57128
return [
58129
'LDAPDirectory' => [
59130
'x-version-introduced' => '2.0',
@@ -145,6 +216,54 @@ public static function getRawKnownSchemas(): array
145216
},
146217
],
147218
],
219+
'SLM' => [
220+
'x-version-introduced' => '2.1.0',
221+
'x-itemtype' => SLM::class,
222+
'type' => Doc\Schema::TYPE_OBJECT,
223+
'properties' => [
224+
'id' => [
225+
'type' => Doc\Schema::TYPE_INTEGER,
226+
'format' => Doc\Schema::FORMAT_INTEGER_INT64,
227+
'readOnly' => true,
228+
],
229+
'name' => ['type' => Doc\Schema::TYPE_STRING],
230+
'entity' => self::getDropdownTypeSchema(class: Entity::class, full_schema: 'Entity'),
231+
'is_recursive' => ['type' => Doc\Schema::TYPE_BOOLEAN],
232+
'comment' => ['type' => Doc\Schema::TYPE_STRING],
233+
'use_ticket_calendar' => ['type' => Doc\Schema::TYPE_BOOLEAN],
234+
'calendar' => self::getDropdownTypeSchema(class: Calendar::class, full_schema: 'Calendar'),
235+
'date_creation' => ['type' => Doc\Schema::TYPE_STRING, 'format' => Doc\Schema::FORMAT_STRING_DATE_TIME],
236+
'date_mod' => ['type' => Doc\Schema::TYPE_STRING, 'format' => Doc\Schema::FORMAT_STRING_DATE_TIME],
237+
],
238+
],
239+
'SLA' => [
240+
'x-version-introduced' => '2.1.0',
241+
'x-itemtype' => SLA::class,
242+
'type' => Doc\Schema::TYPE_OBJECT,
243+
'properties' => $base_la_properties,
244+
],
245+
'OLA' => [
246+
'x-version-introduced' => '2.1.0',
247+
'x-itemtype' => OLA::class,
248+
'type' => Doc\Schema::TYPE_OBJECT,
249+
'properties' => $base_la_properties,
250+
],
251+
'SLALevel' => [
252+
'x-version-introduced' => '2.1.0',
253+
'x-itemtype' => SlaLevel::class,
254+
'type' => Doc\Schema::TYPE_OBJECT,
255+
'properties' => $base_la_level_properties + [
256+
'sla' => self::getDropdownTypeSchema(class: SLA::class, full_schema: 'SLA'),
257+
],
258+
],
259+
'OLALevel' => [
260+
'x-version-introduced' => '2.1.0',
261+
'x-itemtype' => OlaLevel::class,
262+
'type' => Doc\Schema::TYPE_OBJECT,
263+
'properties' => $base_la_level_properties + [
264+
'ola' => self::getDropdownTypeSchema(class: OLA::class, full_schema: 'OLA'),
265+
],
266+
],
148267
];
149268
}
150269

0 commit comments

Comments
 (0)