3636namespace Glpi \Api \HL \Controller ;
3737
3838use AuthLDAP ;
39+ use Calendar ;
3940use CommonDBTM ;
4041use Config ;
42+ use Entity ;
4143use Glpi \Api \HL \Doc as Doc ;
4244use Glpi \Api \HL \Middleware \ResultFormatterMiddleware ;
4345use Glpi \Api \HL \ResourceAccessor ;
4648use Glpi \Http \JSONResponse ;
4749use Glpi \Http \Request ;
4850use 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 ' ])]
5158final 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