Skip to content

Commit c993d39

Browse files
cconard96cedric-anne
authored andcommitted
hlapi add slm features
1 parent dc8112c commit c993d39

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;
@@ -200,6 +204,39 @@ public static function getRawKnownSchemas(): array
200204
'type' => Doc\Schema::TYPE_INTEGER,
201205
'readOnly' => true,
202206
],
207+
'begin_waiting_date' => [
208+
'x-version-introduced' => '2.1.0',
209+
'type' => Doc\Schema::TYPE_STRING,
210+
'readOnly' => true,
211+
'format' => Doc\Schema::FORMAT_STRING_DATE_TIME,
212+
],
213+
'waiting_duration' => [
214+
'x-version-introduced' => '2.1.0',
215+
'type' => Doc\Schema::TYPE_INTEGER,
216+
'readOnly' => true,
217+
'description' => 'Total waiting duration in seconds',
218+
],
219+
'resolution_duration' => [
220+
'x-version-introduced' => '2.1.0',
221+
'type' => Doc\Schema::TYPE_INTEGER,
222+
'readOnly' => true,
223+
'x-field' => 'solve_delay_stat',
224+
'description' => 'Total resolution duration in seconds',
225+
],
226+
'close_duration' => [
227+
'x-version-introduced' => '2.1.0',
228+
'type' => Doc\Schema::TYPE_INTEGER,
229+
'readOnly' => true,
230+
'x-field' => 'close_delay_stat',
231+
'description' => 'Total close duration in seconds',
232+
],
233+
'resolution_date' => [
234+
'x-version-introduced' => '2.1.0',
235+
'type' => Doc\Schema::TYPE_STRING,
236+
'format' => Doc\Schema::FORMAT_STRING_DATE_TIME,
237+
'readOnly' => true,
238+
'x-field' => 'time_to_resolve',
239+
],
203240
'date_creation' => ['type' => Doc\Schema::TYPE_STRING, 'format' => Doc\Schema::FORMAT_STRING_DATE_TIME],
204241
'date_mod' => ['type' => Doc\Schema::TYPE_STRING, 'format' => Doc\Schema::FORMAT_STRING_DATE_TIME],
205242
'date' => ['type' => Doc\Schema::TYPE_STRING, 'format' => Doc\Schema::FORMAT_STRING_DATE_TIME],
@@ -374,6 +411,66 @@ public static function getRawKnownSchemas(): array
374411
'type' => Doc\Schema::TYPE_STRING,
375412
];
376413
$schemas[$itil_type]['properties']['request_type'] = self::getDropdownTypeSchema(class: RequestType::class, full_schema: 'RequestType');
414+
415+
// SLA/OLA Properties
416+
$schemas[$itil_type]['properties']['take_into_account_date'] = [
417+
'x-version-introduced' => '2.1.0',
418+
'type' => Doc\Schema::TYPE_STRING,
419+
'format' => Doc\Schema::FORMAT_STRING_DATE_TIME,
420+
'readOnly' => true,
421+
'x-field' => 'takeintoaccountdate',
422+
];
423+
$schemas[$itil_type]['properties']['take_into_account_duration'] = [
424+
'x-version-introduced' => '2.1.0',
425+
'type' => Doc\Schema::TYPE_INTEGER,
426+
'readOnly' => true,
427+
'description' => 'Total take into account duration in seconds',
428+
'x-field' => 'takeintoaccount_delay_stat',
429+
];
430+
$schemas[$itil_type]['properties']['sla_ttr'] = self::getDropdownTypeSchema(class: SLA::class, field: 'slas_id_ttr', full_schema: 'SLA') + ['x-version-introduced' => '2.1.0'];
431+
$schemas[$itil_type]['properties']['sla_tto'] = self::getDropdownTypeSchema(class: SLA::class, field: 'slas_id_tto', full_schema: 'SLA') + ['x-version-introduced' => '2.1.0'];
432+
$schemas[$itil_type]['properties']['ola_ttr'] = self::getDropdownTypeSchema(class: OLA::class, field: 'olas_id_ttr', full_schema: 'OLA') + ['x-version-introduced' => '2.1.0'];
433+
$schemas[$itil_type]['properties']['ola_tto'] = self::getDropdownTypeSchema(class: OLA::class, field: 'olas_id_tto', full_schema: 'OLA') + ['x-version-introduced' => '2.1.0'];
434+
$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'];
435+
$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'];
436+
$schemas[$itil_type]['properties']['sla_waiting_duration'] = [
437+
'x-version-introduced' => '2.1.0',
438+
'type' => Doc\Schema::TYPE_INTEGER,
439+
'readOnly' => true,
440+
'description' => 'Total SLA waiting duration in seconds',
441+
];
442+
$schemas[$itil_type]['properties']['ola_waiting_duration'] = [
443+
'x-version-introduced' => '2.1.0',
444+
'type' => Doc\Schema::TYPE_INTEGER,
445+
'readOnly' => true,
446+
'description' => 'Total OLA waiting duration in seconds',
447+
];
448+
$schemas[$itil_type]['properties']['ola_ttr_begin_date'] = [
449+
'x-version-introduced' => '2.1.0',
450+
'type' => Doc\Schema::TYPE_STRING,
451+
'readOnly' => true,
452+
'format' => Doc\Schema::FORMAT_STRING_DATE_TIME,
453+
];
454+
$schemas[$itil_type]['properties']['ola_tto_begin_date'] = [
455+
'x-version-introduced' => '2.1.0',
456+
'type' => Doc\Schema::TYPE_STRING,
457+
'readOnly' => true,
458+
'format' => Doc\Schema::FORMAT_STRING_DATE_TIME,
459+
];
460+
$schemas[$itil_type]['properties']['internal_resolution_date'] = [
461+
'x-version-introduced' => '2.1.0',
462+
'type' => Doc\Schema::TYPE_STRING,
463+
'format' => Doc\Schema::FORMAT_STRING_DATE_TIME,
464+
'readOnly' => true,
465+
'x-field' => 'internal_time_to_resolve',
466+
];
467+
$schemas[$itil_type]['properties']['internal_take_into_account_date'] = [
468+
'x-version-introduced' => '2.1.0',
469+
'type' => Doc\Schema::TYPE_STRING,
470+
'format' => Doc\Schema::FORMAT_STRING_DATE_TIME,
471+
'readOnly' => true,
472+
'x-field' => 'internal_time_to_own',
473+
];
377474
}
378475
$schemas[$itil_type]['x-itemtype'] = $itil_type;
379476
$status_description = '';

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

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

3838
use AuthLDAP;
39+
use Calendar;
3940
use CommonDBTM;
41+
use Entity;
4042
use Glpi\Api\HL\Doc as Doc;
4143
use Glpi\Api\HL\Middleware\ResultFormatterMiddleware;
4244
use Glpi\Api\HL\ResourceAccessor;
@@ -45,12 +47,81 @@
4547
use Glpi\Http\JSONResponse;
4648
use Glpi\Http\Request;
4749
use Glpi\Http\Response;
50+
use OLA;
51+
use OlaLevel;
52+
use SLA;
53+
use SlaLevel;
54+
use SLM;
4855

4956
#[Route(path: '/Setup', tags: ['Setup'])]
5057
final class SetupController extends AbstractController
5158
{
5259
public static function getRawKnownSchemas(): array
5360
{
61+
$base_la_properties = [
62+
'id' => [
63+
'type' => Doc\Schema::TYPE_INTEGER,
64+
'format' => Doc\Schema::FORMAT_INTEGER_INT64,
65+
'readOnly' => true,
66+
],
67+
'name' => ['type' => Doc\Schema::TYPE_STRING],
68+
'slm' => self::getDropdownTypeSchema(class: SLM::class, full_schema: 'SLM'),
69+
'entity' => self::getDropdownTypeSchema(class: Entity::class, full_schema: 'Entity'),
70+
'is_recursive' => ['type' => Doc\Schema::TYPE_BOOLEAN],
71+
'type' => [
72+
'type' => Doc\Schema::TYPE_INTEGER,
73+
'enum' => [SLM::TTR, SLM::TTO],
74+
'description' => <<<EOT
75+
- 0: Time to resolve (TTR)
76+
- 1: Time to own (TTO)
77+
EOT,
78+
],
79+
'comment' => ['type' => Doc\Schema::TYPE_STRING],
80+
'time' => [
81+
'type' => Doc\Schema::TYPE_INTEGER,
82+
'x-field' => 'number_time',
83+
'description' => 'Time in the unit defined by the time_unit property',
84+
],
85+
'time_unit' => [
86+
'type' => Doc\Schema::TYPE_STRING,
87+
'enum' => ['minute', 'hour', 'day', 'month'],
88+
'description' => 'Unit of time for the time property',
89+
],
90+
'use_ticket_calendar' => ['type' => Doc\Schema::TYPE_BOOLEAN],
91+
'calendar' => self::getDropdownTypeSchema(class: Calendar::class, full_schema: 'Calendar'),
92+
'end_of_working_day' => [
93+
'type' => Doc\Schema::TYPE_BOOLEAN,
94+
'description' => 'Whether the time computation will target the end of the working day',
95+
],
96+
'date_creation' => ['type' => Doc\Schema::TYPE_STRING, 'format' => Doc\Schema::FORMAT_STRING_DATE_TIME],
97+
'date_mod' => ['type' => Doc\Schema::TYPE_STRING, 'format' => Doc\Schema::FORMAT_STRING_DATE_TIME],
98+
];
99+
100+
$base_la_level_properties = [
101+
'id' => [
102+
'type' => Doc\Schema::TYPE_INTEGER,
103+
'format' => Doc\Schema::FORMAT_INTEGER_INT64,
104+
'readOnly' => true,
105+
],
106+
'uuid' => [
107+
'type' => Doc\Schema::TYPE_STRING,
108+
'pattern' => Doc\Schema::PATTERN_UUIDV4,
109+
'readOnly' => true,
110+
],
111+
'name' => ['type' => Doc\Schema::TYPE_STRING],
112+
'entity' => self::getDropdownTypeSchema(class: Entity::class, full_schema: 'Entity'),
113+
'is_recursive' => ['type' => Doc\Schema::TYPE_BOOLEAN],
114+
'execution_time' => [
115+
'type' => Doc\Schema::TYPE_INTEGER,
116+
'readOnly' => true,
117+
],
118+
'operator' => [
119+
'type' => Doc\Schema::TYPE_STRING,
120+
'enum' => ['AND', 'OR'],
121+
'x-field' => 'match',
122+
],
123+
];
124+
54125
return [
55126
'LDAPDirectory' => [
56127
'x-version-introduced' => '2.0',
@@ -104,6 +175,54 @@ public static function getRawKnownSchemas(): array
104175
],
105176
],
106177
],
178+
'SLM' => [
179+
'x-version-introduced' => '2.1.0',
180+
'x-itemtype' => AuthLDAP::class,
181+
'type' => Doc\Schema::TYPE_OBJECT,
182+
'properties' => [
183+
'id' => [
184+
'type' => Doc\Schema::TYPE_INTEGER,
185+
'format' => Doc\Schema::FORMAT_INTEGER_INT64,
186+
'readOnly' => true,
187+
],
188+
'name' => ['type' => Doc\Schema::TYPE_STRING],
189+
'entity' => self::getDropdownTypeSchema(class: Entity::class, full_schema: 'Entity'),
190+
'is_recursive' => ['type' => Doc\Schema::TYPE_BOOLEAN],
191+
'comment' => ['type' => Doc\Schema::TYPE_STRING],
192+
'use_ticket_calendar' => ['type' => Doc\Schema::TYPE_BOOLEAN],
193+
'calendar' => self::getDropdownTypeSchema(class: Calendar::class, full_schema: 'Calendar'),
194+
'date_creation' => ['type' => Doc\Schema::TYPE_STRING, 'format' => Doc\Schema::FORMAT_STRING_DATE_TIME],
195+
'date_mod' => ['type' => Doc\Schema::TYPE_STRING, 'format' => Doc\Schema::FORMAT_STRING_DATE_TIME],
196+
],
197+
],
198+
'SLA' => [
199+
'x-version-introduced' => '2.1.0',
200+
'x-itemtype' => SLA::class,
201+
'type' => Doc\Schema::TYPE_OBJECT,
202+
'properties' => $base_la_properties,
203+
],
204+
'OLA' => [
205+
'x-version-introduced' => '2.1.0',
206+
'x-itemtype' => OLA::class,
207+
'type' => Doc\Schema::TYPE_OBJECT,
208+
'properties' => $base_la_properties,
209+
],
210+
'SLALevel' => [
211+
'x-version-introduced' => '2.1.0',
212+
'x-itemtype' => SlaLevel::class,
213+
'type' => Doc\Schema::TYPE_OBJECT,
214+
'properties' => $base_la_level_properties + [
215+
'sla' => self::getDropdownTypeSchema(class: SLA::class, full_schema: 'SLA'),
216+
],
217+
],
218+
'OLALevel' => [
219+
'x-version-introduced' => '2.1.0',
220+
'x-itemtype' => OlaLevel::class,
221+
'type' => Doc\Schema::TYPE_OBJECT,
222+
'properties' => $base_la_level_properties + [
223+
'ola' => self::getDropdownTypeSchema(class: OLA::class, full_schema: 'OLA'),
224+
],
225+
],
107226
];
108227
}
109228

0 commit comments

Comments
 (0)