Skip to content
Merged
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
97 changes: 97 additions & 0 deletions src/Glpi/Api/HL/Controller/ITILController.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@
use ITILFollowup;
use ITILSolution;
use Location;
use OLA;
use OlaLevel;
use Planning;
use PlanningEventCategory;
use PlanningExternalEvent;
Expand All @@ -71,6 +73,8 @@
use RecurrentChange;
use RequestType;
use Session;
use SLA;
use SlaLevel;
use TaskCategory;
use Ticket;
use TicketRecurrent;
Expand Down Expand Up @@ -202,6 +206,39 @@ public static function getRawKnownSchemas(): array
'type' => Doc\Schema::TYPE_INTEGER,
'readOnly' => true,
],
'begin_waiting_date' => [
'x-version-introduced' => '2.1.0',
'type' => Doc\Schema::TYPE_STRING,
'readOnly' => true,
'format' => Doc\Schema::FORMAT_STRING_DATE_TIME,
],
'waiting_duration' => [
'x-version-introduced' => '2.1.0',
'type' => Doc\Schema::TYPE_INTEGER,
'readOnly' => true,
'description' => 'Total waiting duration in seconds',
],
'resolution_duration' => [
'x-version-introduced' => '2.1.0',
'type' => Doc\Schema::TYPE_INTEGER,
'readOnly' => true,
'x-field' => 'solve_delay_stat',
'description' => 'Total resolution duration in seconds',
],
'close_duration' => [
'x-version-introduced' => '2.1.0',
'type' => Doc\Schema::TYPE_INTEGER,
'readOnly' => true,
'x-field' => 'close_delay_stat',
'description' => 'Total close duration in seconds',
],
'resolution_date' => [
'x-version-introduced' => '2.1.0',
'type' => Doc\Schema::TYPE_STRING,
'format' => Doc\Schema::FORMAT_STRING_DATE_TIME,
'readOnly' => true,
'x-field' => 'time_to_resolve',
],
'date_creation' => ['type' => Doc\Schema::TYPE_STRING, 'format' => Doc\Schema::FORMAT_STRING_DATE_TIME],
'date_mod' => ['type' => Doc\Schema::TYPE_STRING, 'format' => Doc\Schema::FORMAT_STRING_DATE_TIME],
'date' => ['type' => Doc\Schema::TYPE_STRING, 'format' => Doc\Schema::FORMAT_STRING_DATE_TIME],
Expand Down Expand Up @@ -388,6 +425,66 @@ public static function getRawKnownSchemas(): array
'type' => Doc\Schema::TYPE_STRING,
];
$schemas[$itil_type]['properties']['request_type'] = self::getDropdownTypeSchema(class: RequestType::class, full_schema: 'RequestType');

// SLA/OLA Properties
$schemas[$itil_type]['properties']['take_into_account_date'] = [
'x-version-introduced' => '2.1.0',
'type' => Doc\Schema::TYPE_STRING,
'format' => Doc\Schema::FORMAT_STRING_DATE_TIME,
'readOnly' => true,
'x-field' => 'takeintoaccountdate',
];
$schemas[$itil_type]['properties']['take_into_account_duration'] = [
'x-version-introduced' => '2.1.0',
'type' => Doc\Schema::TYPE_INTEGER,
'readOnly' => true,
'description' => 'Total take into account duration in seconds',
'x-field' => 'takeintoaccount_delay_stat',
];
$schemas[$itil_type]['properties']['sla_ttr'] = self::getDropdownTypeSchema(class: SLA::class, field: 'slas_id_ttr', full_schema: 'SLA') + ['x-version-introduced' => '2.1.0'];
$schemas[$itil_type]['properties']['sla_tto'] = self::getDropdownTypeSchema(class: SLA::class, field: 'slas_id_tto', full_schema: 'SLA') + ['x-version-introduced' => '2.1.0'];
$schemas[$itil_type]['properties']['ola_ttr'] = self::getDropdownTypeSchema(class: OLA::class, field: 'olas_id_ttr', full_schema: 'OLA') + ['x-version-introduced' => '2.1.0'];
$schemas[$itil_type]['properties']['ola_tto'] = self::getDropdownTypeSchema(class: OLA::class, field: 'olas_id_tto', full_schema: 'OLA') + ['x-version-introduced' => '2.1.0'];
$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'];
$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'];
$schemas[$itil_type]['properties']['sla_waiting_duration'] = [
'x-version-introduced' => '2.1.0',
'type' => Doc\Schema::TYPE_INTEGER,
'readOnly' => true,
'description' => 'Total SLA waiting duration in seconds',
];
$schemas[$itil_type]['properties']['ola_waiting_duration'] = [
'x-version-introduced' => '2.1.0',
'type' => Doc\Schema::TYPE_INTEGER,
'readOnly' => true,
'description' => 'Total OLA waiting duration in seconds',
];
$schemas[$itil_type]['properties']['ola_ttr_begin_date'] = [
'x-version-introduced' => '2.1.0',
'type' => Doc\Schema::TYPE_STRING,
'readOnly' => true,
'format' => Doc\Schema::FORMAT_STRING_DATE_TIME,
];
$schemas[$itil_type]['properties']['ola_tto_begin_date'] = [
'x-version-introduced' => '2.1.0',
'type' => Doc\Schema::TYPE_STRING,
'readOnly' => true,
'format' => Doc\Schema::FORMAT_STRING_DATE_TIME,
];
$schemas[$itil_type]['properties']['internal_resolution_date'] = [
'x-version-introduced' => '2.1.0',
'type' => Doc\Schema::TYPE_STRING,
'format' => Doc\Schema::FORMAT_STRING_DATE_TIME,
'readOnly' => true,
'x-field' => 'internal_time_to_resolve',
];
$schemas[$itil_type]['properties']['internal_take_into_account_date'] = [
'x-version-introduced' => '2.1.0',
'type' => Doc\Schema::TYPE_STRING,
'format' => Doc\Schema::FORMAT_STRING_DATE_TIME,
'readOnly' => true,
'x-field' => 'internal_time_to_own',
];
}
if ($itil_type === Ticket::class || $itil_type === Change::class) {
$schemas[$itil_type]['properties']['global_validation'] = [
Expand Down
119 changes: 119 additions & 0 deletions src/Glpi/Api/HL/Controller/SetupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@
namespace Glpi\Api\HL\Controller;

use AuthLDAP;
use Calendar;
use CommonDBTM;
use Config;
use Entity;
use Glpi\Api\HL\Doc as Doc;
use Glpi\Api\HL\Middleware\ResultFormatterMiddleware;
use Glpi\Api\HL\ResourceAccessor;
Expand All @@ -46,6 +48,11 @@
use Glpi\Http\JSONResponse;
use Glpi\Http\Request;
use Glpi\Http\Response;
use OLA;
use OlaLevel;
use SLA;
use SlaLevel;
use SLM;

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

$base_la_properties = [
'id' => [
'type' => Doc\Schema::TYPE_INTEGER,
'format' => Doc\Schema::FORMAT_INTEGER_INT64,
'readOnly' => true,
],
'name' => ['type' => Doc\Schema::TYPE_STRING],
'slm' => self::getDropdownTypeSchema(class: SLM::class, full_schema: 'SLM'),
'entity' => self::getDropdownTypeSchema(class: Entity::class, full_schema: 'Entity'),
'is_recursive' => ['type' => Doc\Schema::TYPE_BOOLEAN],
'type' => [
'type' => Doc\Schema::TYPE_INTEGER,
'enum' => [SLM::TTR, SLM::TTO],
'description' => <<<EOT
- 0: Time to resolve (TTR)
- 1: Time to own (TTO)
EOT,
],
'comment' => ['type' => Doc\Schema::TYPE_STRING],
'time' => [
'type' => Doc\Schema::TYPE_INTEGER,
'x-field' => 'number_time',
'description' => 'Time in the unit defined by the time_unit property',
],
'time_unit' => [
'type' => Doc\Schema::TYPE_STRING,
'enum' => ['minute', 'hour', 'day', 'month'],
'description' => 'Unit of time for the time property',
],
'use_ticket_calendar' => ['type' => Doc\Schema::TYPE_BOOLEAN],
'calendar' => self::getDropdownTypeSchema(class: Calendar::class, full_schema: 'Calendar'),
'end_of_working_day' => [
'type' => Doc\Schema::TYPE_BOOLEAN,
'description' => 'Whether the time computation will target the end of the working day',
],
'date_creation' => ['type' => Doc\Schema::TYPE_STRING, 'format' => Doc\Schema::FORMAT_STRING_DATE_TIME],
'date_mod' => ['type' => Doc\Schema::TYPE_STRING, 'format' => Doc\Schema::FORMAT_STRING_DATE_TIME],
];

$base_la_level_properties = [
'id' => [
'type' => Doc\Schema::TYPE_INTEGER,
'format' => Doc\Schema::FORMAT_INTEGER_INT64,
'readOnly' => true,
],
'uuid' => [
'type' => Doc\Schema::TYPE_STRING,
'pattern' => Doc\Schema::PATTERN_UUIDV4,
'readOnly' => true,
],
'name' => ['type' => Doc\Schema::TYPE_STRING],
'entity' => self::getDropdownTypeSchema(class: Entity::class, full_schema: 'Entity'),
'is_recursive' => ['type' => Doc\Schema::TYPE_BOOLEAN],
'execution_time' => [
'type' => Doc\Schema::TYPE_INTEGER,
'readOnly' => true,
],
'operator' => [
'type' => Doc\Schema::TYPE_STRING,
'enum' => ['AND', 'OR'],
'x-field' => 'match',
],
];

return [
'LDAPDirectory' => [
'x-version-introduced' => '2.0',
Expand Down Expand Up @@ -145,6 +216,54 @@ public static function getRawKnownSchemas(): array
},
],
],
'SLM' => [
'x-version-introduced' => '2.1.0',
'x-itemtype' => SLM::class,
'type' => Doc\Schema::TYPE_OBJECT,
'properties' => [
'id' => [
'type' => Doc\Schema::TYPE_INTEGER,
'format' => Doc\Schema::FORMAT_INTEGER_INT64,
'readOnly' => true,
],
'name' => ['type' => Doc\Schema::TYPE_STRING],
'entity' => self::getDropdownTypeSchema(class: Entity::class, full_schema: 'Entity'),
'is_recursive' => ['type' => Doc\Schema::TYPE_BOOLEAN],
'comment' => ['type' => Doc\Schema::TYPE_STRING],
'use_ticket_calendar' => ['type' => Doc\Schema::TYPE_BOOLEAN],
'calendar' => self::getDropdownTypeSchema(class: Calendar::class, full_schema: 'Calendar'),
'date_creation' => ['type' => Doc\Schema::TYPE_STRING, 'format' => Doc\Schema::FORMAT_STRING_DATE_TIME],
'date_mod' => ['type' => Doc\Schema::TYPE_STRING, 'format' => Doc\Schema::FORMAT_STRING_DATE_TIME],
],
],
'SLA' => [
'x-version-introduced' => '2.1.0',
'x-itemtype' => SLA::class,
'type' => Doc\Schema::TYPE_OBJECT,
'properties' => $base_la_properties,
],
'OLA' => [
'x-version-introduced' => '2.1.0',
'x-itemtype' => OLA::class,
'type' => Doc\Schema::TYPE_OBJECT,
'properties' => $base_la_properties,
],
'SLALevel' => [
'x-version-introduced' => '2.1.0',
'x-itemtype' => SlaLevel::class,
'type' => Doc\Schema::TYPE_OBJECT,
'properties' => $base_la_level_properties + [
'sla' => self::getDropdownTypeSchema(class: SLA::class, full_schema: 'SLA'),
],
],
'OLALevel' => [
'x-version-introduced' => '2.1.0',
'x-itemtype' => OlaLevel::class,
'type' => Doc\Schema::TYPE_OBJECT,
'properties' => $base_la_level_properties + [
'ola' => self::getDropdownTypeSchema(class: OLA::class, full_schema: 'OLA'),
],
],
];
}

Expand Down
Loading