Core - Service Rules

Module dedicated to service rules. Service rules links a vehicle group to a user group, specifying that the user in the user group can use the vehicles in the vehicle group

The base url for the APIs in this page is at:

/api/admin

A JSON file with OpenAPI data about all core-related admin APIs can be downloaded here.

Get service rules list

The method returns a list of service rules grouped by user group (it’s a Paged List APIs, as explained in the introduction):

GET /v1/service-rules/list

Gets the list of service rules

Status Codes

Returns the list of all existing service rules:

[
  {
    GroupID: 1234,                                // Int
    Labels: "{\"en\":\"Default Group\",...}",     // String
    ModuleID: 2,                                  // ID
    ModuleName: "Vehicle Sharing",                // String
    Rules: "London, Milan, Venice, ...",          // String
    RulesIDs: [1,2,3,...]                         // Int Array
  },
  ...
]

The Labels property contains a stringified Json containing pairs “language code”:”localized value”

The Rules property is a string composed of the allowed external resources groups’ names divided by a comma, while the RulesIDs property is an array with the groups’ IDs.

Get service rules by module and user group

Gets the list of service rules for a specific module and user group (it’s a Paged List APIs, as explained in the introduction):

GET /v1/service-rules/rules/list/{m}/{g}

Gets the data for a specified module and resource group, and the list of service rules

Parameters
  • m (integer) – The id of the module

  • g (integer) – The id of the resource group

Status Codes
m: The id of the module (int)
g: The id of the user group (int)

Returns the list of service rules for the module and user group corresponding to the IDs provided in the request:

[
  {
    GroupID: 1234,                                // Int
    Labels: "{\"en\":\"Default Group\",...}",     // String
    ModuleID: 2,                                  // ID
    ModuleName: "Vehicle Sharing",                // String
    Rules: "London, Milan, Venice, ...",          // String
    RulesIDs: [1,2,3,...]                         // Int Array
  },
  ...
]

The Labels property contains a stringified Json containing pairs “language code”:”localized value”

The Rules property is a string composed of the allowed external resources groups’ names divided by a comma, while the RulesIDs property is an array with the groups’ IDs.

Get service rules description by module and user group

Gets the description of service rules for a specific module and user group:

GET /v1/service-rules/{m}/{g}

Gets the list of service rules for a specific module and resource group

Parameters
  • m (integer) – The id of the module

  • g (integer) – The id of the resource group

Status Codes
m: The id of the module (int)
g: The id of the user group (int)

Returns a positive Json response and the list of service rules:

{
  GroupID: 1234,                                // Int
  Labels: "{\"en\":\"Default Group\",...}",     // String
  ModuleID: 2,                                  // ID
  ModuleName: "Vehicle Sharing",                // String
  Rules: "London, Milan, Venice, ...",          // String
  RulesIDs: [1,2,3,...]                         // Int Array
}

The Labels property contains a stringified Json containing pairs “language code”:”localized value”

The Rules property is a string composed of the allowed external resources groups’ names divided by a comma, while the RulesIDs property is an array with the groups’ IDs.

Get modules

Gets the list of modules in the system:

GET /v1/service-rules/modules

Gets the list of modules in the system

Status Codes

Returns a positive Json response and the list of modules:

[
  {
    ID: 123,                                    // Int
    Name: "Module_Name"                         // String
  },
  ...
]

Edit existing service rule

Persists edits about an existing service rule:

POST /v1/service-rules

Persists edits about an existing service rule

Status Codes

With a request body like this:

{
  ID: 123,                                      // Int (Required)
  EquivalentCategoriesAllowed: "B"              // String
}

It returns a plain Json positive response if the record was successfully updated, or a plain Json negative response if the ID provided does not correspond to any existing record.

Get service rules by user group

Gets a list of rules for a specific user group (it’s a Paged List APIs, as explained in the introduction):

GET /v1/service-rules/group-rules/{gid}

Gets a list of rules for a specific resource group

Parameters
  • gid (integer) – The id of an external resource group

Status Codes
gid: The id of an external user group (int)

The result will be a list as this:

[
  {
    ID: 1234,                                           // Int
    EquivalentCategoriesAllowed: "B",                   // String
    ExtGrpID: 1,                                        // Int
    ExtGrpGuid: "e0828997-d3ce-40e2-adcd-e3248ea536e0", // Guid
    Name: "London", //Vehicle group name                // String
    Description: "Description"                          // String
  },
  ...
]

where ExtGrpID and ExtGrpGuid are respectively the ID and Guid for the involved external group

Add new service rule by user group and module

Persists edits about a new user group and module service rule:

POST /v1/service-rules/group-rules

Persists edits about a new or existing resource group service rule

Status Codes

With a request body like this:

{
  GroupID: 123,                               // Int
  ModuleID: 456,                              // Int
  IsNew: true,                                // Boolean (nullable)
  RuleIDs: [1,2,3]                            // Int Array (Vehicle groups ID array)
}

where RuleIDs is the list of ID for the involved external groups, and ModuleID is the ID of the module originating said groups. If the IsNew property is set to null it will be interpreted as false.

Returns a plain Json positive response if the record was successfully updated or a plain Json negative one if there was an error saving the changes.

Other possible error messages are:

err_NoGroupFound

No corresponding group found for the GroupID provided

err_NoModuleFound

No corresponding module found for the ModuleID provided

err_DuplicateElement

Rule group already exists for the group and module provided in the request