Restrictions API
Restrictions API service allows you to manage information about road closures: get a list of currently active road closures, add new road closures, and remove the ones that are no longer relevant. All road closures added via Restrictions API will be taken into account when building routes using On-Premise Navigation services.
Restrictions API service publishes a RESTful API for use by a client application.
Architecture
Restrictions API service integrates with On-Premise Navigation services (Navi-Castle and Navi-Back) to obtain geographic data. In addition, the service uses a cron job to periodically (once per hour) retrieve current road closure information from public 2GIS Update servers.

Requirements
Shared infrastructure:
- PostgreSQL data storage for storing road closure data. It is required to deploy PostgreSQL 12 with PL/pgSQL enabled.
Services:
Installing
-
Create the
values-restrictions.yaml
configuration file:values-restrictions.yaml
dgctlDockerRegistry: <Docker Registry hostname and port>/2gis-on-premise db: host: <hostname or IP address of PostgreSQL> port: <PostgreSQL port> path: <database name> username: <user name> password: <password> api: attractor_url: <Navi-Back URL (ex. "https://example.com:80")>
Where:
-
dgctlDockerRegistry
: your Docker Registry endpoint where On-Premise services' images reside. -
db
: access settings for the PostgreSQL server.host
: hostname or IP address of the PostgreSQL server.port
: listening port of the PostgreSQL server. For example,5432
.path
: database name.username
andpassword
: credentials for accessing the database specified in thepath
setting. The user must be the owner of this database or a superuser.
-
attractor_url
: URL of Navi-Back service. This URL should be accessible from all the pods within your Kubernetes cluster.
-
-
Deploy the service with Helm using the created
values-restrictions.yaml
configuration file:
helm upgrade --install --version=1.0.3 --atomic --wait-for-jobs --values ./values-restrictions.yaml navi-restrictions 2gis-on-premise/navi-restrictions
Updating
To update the service after changing the settings or after updating the Docker image, call helm upgrade
command:
helm upgrade --version=1.0.3 --atomic --wait-for-jobs --values ./values-restrictions.yaml navi-restrictions 2gis-on-premise/navi-restrictions
Using RESTful API
Adding road closure
To add a road closure, send a POST request to the /points
endpoint.
The body of the request must contain a JSON object with the following attributes:
lat
- latitude of the road closure.lon
- longitude of the road closure.start_time
- date and time of the start of the road closure in RFC 3339 format (for example, 2020-05-15T15:52:01Z).end_time
- date and time of the end of the road closure in RFC 3339 format (for example, 2020-05-15T15:52:01Z).
{
"lat": "54.943207",
"lon": "82.93057",
"start_time": "2022-03-01T12:00:00Z",
"end_time": "2022-04-01T12:00:00Z"
}
If the road closure was successfully added, the response will contain a UUID that can be used to update the road closure or delete it from the database.
Getting active road closures
To get a list of currently active road closures, send a GET request to the /restrictions
endpoint.
The request will return the following information:
restriction_id
- UUID of the road closure.edge_geometry
- geometry of the road closure in WKT format.start_time
- date and time of the start of the road closure in RFC 3339 format (for example, 2020-05-15T15:52:01Z).end_time
- date and time of the end of the road closure in RFC 3339 format (for example, 2020-05-15T15:52:01Z).
[
{
"restriction_id": "ca89008e-186b-4a97-942b-739b646b6952",
"edge_geometry": "...",
"start_time": "2022-03-01T12:00:00Z",
"end_time": "2022-04-01T12:00:00Z"
}
]
Updating road closure
To update the time of a road closure, send a PATCH request to the /restrictions/{id}
endpoint, where {id}
is the UUID of the road closure.
The body of the request must contain a JSON object with the following attributes:
start_time
- date and time of the start of the road closure in RFC 3339 format (for example, 2020-05-15T15:52:01Z).end_time
- date and time of the end of the road closure in RFC 3339 format (for example, 2020-05-15T15:52:01Z).
{
"start_time": "2022-03-01T12:00:00Z",
"end_time": "2022-04-01T12:00:00Z"
}
Deleting road closure
To delete a road closure, send a DELETE request to the /restrictions/{id}
endpoint, where {id}
is the UUID of the road closure.
On a successful request, the road closure will be marked as removed and no longer will be taken into account when building routes. All road closures marked this way as well as closures with an end date less than or equal to the current date will be deleted from the database on the next cleanup cycle.
Testing the deployment
To test that the service is working, send a GET request to the /healthcheck
endpoint.