5.1.2. Resources

5.1.2.1. Universal sets of permissions

class nextgisweb.resource.scope.ResourceScope[source]

Base set of resource permissions

read = <Permission 'read' in scope 'resource'>

Read: ability to read class, name and key of the resource. Most of the other permissions depend on Read, for example Update, so you can’t change a resource if you can’t read it.

create = <Permission 'create' in scope 'resource'>

Create: a little bit fuzzy rule that is not used currently. The idea was to check Create permission while creating a new resource, but currenty only manage_children permission is checked for child resource. Possibly will have to return to this one as it is impossible to restrict creation of resources with certain types without this rule.

update = <Permission 'update' in scope 'resource'>

Update: change name and key of the resource analogous to read. Doesn’t affect changes to any other attributes.

delete = <Permission 'delete' in scope 'resource'>

Delete: permission to remove this resource. Besides that to really remove a resource one will also need manage_children permission for parent resource.

manage_children = <Permission 'manage_children' in scope 'resource'>

Manage children resources

change_permissions = <Permission 'change_permissions' in scope 'resource'>

Manage permissions

class nextgisweb.resource.scope.MetadataScope[source]

Set of permissions for resource metadata. Typical example of resource metadata - is its description in free form. This description doesn’t affect anything it’s change doesn’t change data structure or anything else. As every resource has description this set of permissions is included for all resources at Resource class level.

read = <Permission 'read' in scope 'metadata'>

Read

write = <Permission 'write' in scope 'metadata'>

Write

class nextgisweb.resource.scope.DataStructureScope[source]

Set of permissions for data structure, for example fields structure of vector layer, its change might lead to change in data itself.

read = <Permission 'read' in scope 'datastruct'>

Read

write = <Permission 'write' in scope 'datastruct'>

Write

class nextgisweb.resource.scope.DataScope[source]

Set of permissions for data access

read = <Permission 'read' in scope 'data'>

Read

write = <Permission 'write' in scope 'data'>

Write

class nextgisweb.resource.scope.ConnectionScope[source]

Set of permissions for external connection parameters. In some cases we need to store access parameters to external resources. These parameters may be sensitive, logins and passwords to access remote DB for example.

class nextgisweb.resource.scope.ServiceScope[source]

Set of permissions for services such as WMS or WFS. This is needed to separate permissions for service parameters and its actual usage. Though if service is using other resources inside, we need to their permissions separately.

connect = <Permission 'connect' in scope 'service'>

Connection

configure = <Permission 'configure' in scope 'service'>

Configuration

5.1.2.2. Resource classes

There are following resource classes now:

  • resource_group
  • postgis_layer
  • wmsserver_service
  • baselayers
  • postgis_connection
  • webmap
  • wfsserver_service
  • vector_layer
  • raster_layer
  • vector_style
  • raster_style
  • file_bucket
  • lookup_table
  • wmsclient_layer
  • wmsclient_connection

5.1.2.3. HTTP API

5.1.2.3.1. Version

New in version 3.0.

To get NextGIS Web API version execute the following request:

GET /api/component/pyramid/pkg_version

Example request:

GET /api/component/pyramid/pkg_version HTTP/1.1
Host: ngw_url
Accept: */*

Example JSON response:

{
   "nextgisweb": "2.0",
   "nextgisweb_mapserver": "0.0dev"
}

5.1.2.3.2. Routes

New in version 3.0.

Routes are the REST API URLs which are supported by current instance of NextGIS Web. To get possible routes execute the following request:

GET /api/component/pyramid/route

Example request:

GET /api/component/pyramid/route HTTP/1.1
Host: ngw_url
Accept: */*

Example JSON response:

{
    "pyramid.settings": [
        "/api/component/pyramid/settings"
    ],
    "feature_layer.store.item": [
        "/resource/{0}/store/{1}",
        "id",
        "feature_id"
    ],
    "feature_layer.feature.update": [
        "/resource/{0}/feature/{1}/update",
        "id",
        "feature_id"
    ],
    ...
    "pyramid.statistics": [
        "/api/component/pyramid/statistics"
    ],
    "feature_layer.feature.item": [
        "/api/resource/{0}/feature/{1}",
        "id",
        "fid"
    ],
    "pyramid.pkg_version": [
        "/api/component/pyramid/pkg_version"
    ]
}

5.1.2.3.3. Schema

Schema request returns list of supported NextGIS Web resources, each resource type properties and metadata.

GET /resource/schema

Schema request.

Note

REST API requests require accept field in header with following text: Accept: */*

Example request:

GET /resource/schema HTTP/1.1
Host: ngw_url
Accept: */*

Example JSON response:

{
    "scopes": {
        "resource": {
            "label": "Ресурс",
            "identity": "resource",
            "permissions": {
                "manage_children": {
                    "label": "Manage child resources"
                },
                "change_permissions": {
                    "label": "Change permissions"
                },
                "read": {
                    "label": "Read"
                },
                "create": {
                    "label": "Create"
                },
                "update": {
                    "label": "Modify"
                },
                "delete": {
                    "label": "Delete"
                }
            }
        },
        "service": {
            "label": "Сервис",
            "identity": "service",
            "permissions": {
                "connect": {
                    "label": "Connection"
                },
                "configure": {
                    "label": "Configure"
                }
            }
        },
        "datastruct": {
            "label": "Data structure",
            "identity": "datastruct",
            "permissions": {
                "write": {
                    "label": "White"
                },
                "read": {
                    "label": "Read"
                }
            }
        },
        "connection": {
            "label": "Connection",
            "identity": "connection",
            "permissions": {
                "write": {
                    "label": "Write"
                },
                "read": {
                    "label": "Read"
                },
                "connect": {
                    "label": "Connect"
                }
            }
        },
        "webmap": {
            "label": "Web-map",
            "identity": "webmap",
            "permissions": {
                "display": {
                    "label": "Open"
                }
            }
        },
        "data": {
            "label": "Data",
            "identity": "data",
            "permissions": {
                "write": {
                    "label": "Write"
                },
                "read": {
                    "label": "Read"
                }
            }
        },
        "metadata": {
            "label": "Metadata",
            "identity": "metadata",
            "permissions": {
                "write": {
                    "label": "Write"
                },
                "read": {
                    "label": "Read"
                }
            }
        }
    },
    "resources": {
        "raster_style": {
            "scopes": [
                "resource",
                "data",
                "metadata"
            ],
            "identity": "raster_style",
            "label": "Raster style"
        },
        "resource": {
            "scopes": [
                "resource",
                "metadata"
            ],
            "identity": "resource",
            "label": "Resource"
        },
        "postgis_connection": {
            "scopes": [
                "connection",
                "resource",
                "metadata"
            ],
            "identity": "postgis_connection",
            "label": "PostGIS connection"
        },
        "resource_group": {
            "scopes": [
                "resource",
                "metadata"
            ],
            "identity": "resource_group",
            "label": "Resource group"
        },
        "wmsclient_connection": {
            "scopes": [
                "connection",
                "resource",
                "metadata"
            ],
            "identity": "wmsclient_connection",
            "label": "WMS connection"
        },
        "mapserver_style": {
            "scopes": [
                "resource",
                "data",
                "metadata"
            ],
            "identity": "mapserver_style",
            "label": "MapServer style"
        },
        "vector_layer": {
            "scopes": [
                "resource",
                "datastruct",
                "data",
                "metadata"
            ],
            "identity": "vector_layer",
            "label": "Vector layer"
        },
        "qgis_vector_style": {
            "scopes": [
                "resource",
                "data",
                "metadata"
            ],
            "identity": "qgis_vector_style",
            "label": "QGIS style"
        },
        "wmsclient_layer": {
            "scopes": [
                "resource",
                "datastruct",
                "data",
                "metadata"
            ],
            "identity": "wmsclient_layer",
            "label": "WMS layer"
        },
        "basemap_layer": {
            "scopes": [
                "resource",
                "data",
                "metadata"
            ],
            "identity": "basemap_layer",
            "label": "Basemap"
        },
        "wfsserver_service": {
            "scopes": [
                "resource",
                "service",
                "metadata"
            ],
            "identity": "wfsserver_service",
            "label": "WFS service"
        },
        "lookup_table": {
            "scopes": [
                "resource",
                "data",
                "metadata"
            ],
            "identity": "lookup_table",
            "label": "Reference"
        },
        "postgis_layer": {
            "scopes": [
                "resource",
                "datastruct",
                "data",
                "metadata"
            ],
            "identity": "postgis_layer",
            "label": "PostGIS layer"
        },
        "webmap": {
            "scopes": [
                "resource",
                "webmap",
                "metadata"
            ],
            "identity": "webmap",
            "label": "Web map"
        },
        "wmsserver_service": {
            "scopes": [
                "resource",
                "service",
                "metadata"
            ],
            "identity": "wmsserver_service",
            "label": "WMS service"
        },
        "raster_layer": {
            "scopes": [
                "resource",
                "datastruct",
                "data",
                "metadata"
            ],
            "identity": "raster_layer",
            "label": "Raster layer"
        }
    }
}

5.1.2.3.4. Requests to root

Deprecated since version 2.2.

GET /resource/-/child/

Root resource (list).

Deprecated since version 2.2.

GET /resource/-/child/(int: id)

Get resource by identificator id.

GET /resource/(int: id)/child/

Child resources of resource with identificator id (list).

GET /resource/(int: parent_id)/child/(int: id)

Resource with identificator id (object).

Deprecated since version 2.2.

GET /resource/store/

All resource list.

Deprecated since version 2.2.

GET /resource/store/(int: id)

Resource with identificator id (object).

Deprecated since version 2.2.

GET /resource/store/?id=(int: id)

Resource with identificator id (object).

Deprecated since version 2.2.

GET /resource/store/?parent_id=(int: id)

Child resources of resource with identificator id (list).

5.1.2.3.5. Basic requests

GET /api/resource/(int: id)

Get JSON resource representation. Need resource read permission.

PUT /api/resource/(int: id)

Change resource by JSON payload data. Need read and write permissions.

DELETE /api/resource/(int: id)

Delete resource.

GET /api/resource/

Get resource description in JSON.

Parameters:
  • parent (integer) – Parent resource identificator.
POST /api/resource/

Create resource by JSON data payload.

Parameters:
  • parent (integer) – Parent resource identificator, may be in JSON payload.
  • cls (string) – Resource class (type). For a list of supported resource classes see Resource classes.

5.1.2.3.6. Child resource

To get child resources of parent resource with identificator id execute the following request:

GET /api/resource/?parent=(int: id)

Example JSON response:

{
        "resource": {
                "id": 730,
                "cls": "webmap",
                "parent": {
                        "id": 640,
                        "parent": {
                                "id": 639
                        }
                },
                "owner_user": {
                        "id": 4
                },
                "permissions": [],
                "keyname": null,
                "display_name": "OpenDroneMap sample",
                "description": null,
                "children": false,
                "interfaces": [],
                "scopes": [
                        "resource",
                        "webmap",
                        "metadata"
                ]
        },
        "webmap": {
                "extent_left": -83.31,
                "extent_right": -83.3,
                "extent_bottom": 41.042,
                "extent_top": 41.034,
                "bookmark_resource": null,
                "root_item": {
                        "item_type": "root",
                        "children": [
                                {
                                        "layer_adapter": "image",
                                        "layer_enabled": true,
                                        "layer_max_scale_denom": null,
                                        "item_type": "layer",
                                        "layer_min_scale_denom": null,
                                        "display_name": "Seneca country",
                                        "layer_style_id": 642,
                                        "layer_transparency": null
                                }
                        ]
                }
        },
        "basemap_webmap": {
                "basemaps": [
                        {
                                "opacity": null,
                                "enabled": true,
                                "position": 0,
                                "display_name": "HikeBikeMap",
                                "resource_id": 1039
                        },
                        {
                                "opacity": null,
                                "enabled": true,
                                "position": 1,
                                "display_name": "Спутник",
                                "resource_id": 1038
                        }
                ]
        },
        "resmeta": {
                "items": {}
        }
},
{
        "resource": {
                "id": 641,
                "cls": "raster_layer",
                "parent": {
                        "id": 640,
                        "parent": {
                                "id": 639
                        }
                },
                "owner_user": {
                        "id": 4
                },
                "permissions": [],
                "keyname": null,
                "display_name": "odm_orthophoto_low",
                "description": null,
                "children": true,
                "interfaces": [
                        "IBboxLayer"
                ],
                "scopes": [
                        "resource",
                        "datastruct",
                        "data",
                        "metadata"
                ]
        },
        "resmeta": {
                "items": {}
        },
        "raster_layer": {
                "srs": {
                        "id": 3857
                },
                "xsize": 16996,
                "ysize": 17054,
                "band_count": 4
        }
},
{
        "resource": {
                "id": 1041,
                "cls": "wfsserver_service",
                "parent": {
                        "id": 640,
                        "parent": {
                                "id": 639
                        }
                },
                "owner_user": {
                        "id": 4
                },
                "permissions": [],
                "keyname": null,
                "display_name": "WFS service for demo",
                "description": null,
                "children": false,
                "interfaces": [],
                "scopes": [
                        "resource",
                        "service",
                        "metadata"
                ]
        },
        "resmeta": {
                "items": {}
        },
        "wfsserver_service": {
                "layers": [
                        {
                                "maxfeatures": 2222,
                                "keyname": "lines",
                                "display_name": "Просеки",
                                "resource_id": 534
                        }
                ]
        }
},
{
        "resource": {
                "id": 1036,
                "cls": "resource_group",
                "parent": {
                        "id": 640,
                        "parent": {
                                "id": 639
                        }
                },
                "owner_user": {
                        "id": 4
                },
                "permissions": [],
                "keyname": null,
                "display_name": "Sample folder",
                "description": null,
                "children": true,
                "interfaces": [],
                "scopes": [
                        "resource",
                        "metadata"
                ]
        },
        "resmeta": {
                "items": {}
        }
},
{
        "resource": {
                "id": 1037,
                "cls": "wmsserver_service",
                "parent": {
                        "id": 640,
                        "parent": {
                                "id": 639
                        }
                },
                "owner_user": {
                        "id": 4
                },
                "permissions": [],
                "keyname": null,
                "display_name": "OpenDroneMap at NextGIS.com",
                "description": null,
                "children": false,
                "interfaces": [],
                "scopes": [
                        "resource",
                        "service",
                        "metadata"
                ]
        },
        "resmeta": {
                "items": {}
        },
        "wmsserver_service": {
                "layers": [
                        {
                                "min_scale_denom": null,
                                "keyname": "seneca_country",
                                "display_name": "Seneca country",
                                "max_scale_denom": null,
                                "resource_id": 642
                        }
                ]
        }
}

5.1.2.3.7. Resource properties

To get resource properties execute the following request:

GET /api/resource/(int: id)

Resource properties.

Example request:

GET /api/resource/1 HTTP/1.1
Host: ngw_url
Accept: */*

Example JSON response:

{
 "resource": {
     "id": 2,
     "cls": "resource_group",
     "parent": {
         "id": 0,
         "parent": {
             "id": null
         }
     },
     "owner_user": {
         "id": 4
     },
     "permissions": [],
     "keyname": null,
     "display_name": "test",
     "description": "",
     "children": true,
     "interfaces": [],
     "scopes": [
         "resource",
         "metadata"
     ]
 },
 "resmeta": {
     "items": {}
 }
}

Where:

  • resource - resource description

    • id - resource identificator
    • cls - resource type (see. Resource classes)
    • parent - parent resource
    • owner_user - resource owner identificator
    • permissions - resource permissions array
    • keyname - unique identificator (allowed only ASCII characters). Must be unique in whole NextGIS Web instance
    • display_name - name showing in web user interface
    • description - resource description showing in web user interface
    • children - boolean value. True if resource has children resources
    • interfaces - API interfaces supported by resource
    • scope - which scope the resource is belongs
  • resmeta - resource metadata

The map resource properties has the following json description:

{
 "resource": {
     "id": 1,
     "cls": "webmap",
     "parent": {
         "id": 2,
         "parent": {
             "id": 0
         }
     },
     "owner_user": {
         "id": 4
     },
     "permissions": [],
     "keyname": null,
     "display_name": "Main web map",
     "description": null,
     "children": false,
     "interfaces": [],
     "scopes": [
         "resource",
         "webmap",
         "metadata"
     ]
 },
 "webmap": {
     "extent_left": -180,
     "extent_right": 180,
     "extent_bottom": -90,
     "extent_top": 90,
     "draw_order_enabled": null,
     "bookmark_resource": null,
     "root_item": {
         "item_type": "root",
         "children": [
             {
                 "layer_adapter": "image",
                 "layer_enabled": true,
                 "draw_order_position": null,
                 "layer_max_scale_denom": null,
                 "item_type": "layer",
                 "layer_min_scale_denom": null,
                 "display_name": "Cities",
                 "layer_style_id": 91,
                 "layer_transparency": null
             },
             {
                 "group_expanded": false,
                 "display_name": "Points of interest",
                 "children": [
                  ],
                 "item_type": "group"
             }
         ]
     }
 },
 "basemap_webmap": {
     "basemaps": [
        {
             "opacity": null,
             "enabled": true,
             "position": 0,
             "display_name": "OpenStreetMap Standard",
             "resource_id": 665
         },
     ]
 },
 "resmeta": {
     "items": {}
 }
}

Where:

  • resource - resource description (see upper for details)

  • webmap - web map description

    • extent_left, extent_right, extent_bottom, extent_top -

    • draw_order_enabled - use specific draw order or same as layers order

    • bookmark_resource - vector layer resource identificator

    • root_item - layers description group

      • item_type - always root

      • children - map layers and groups

        • layer_adapter - image or tile (also see Creation of web map)
        • layer_enabled - is layer checked be default
        • draw_order_position - if drawing order is enabled this is position in order. May be null.
        • layer_max_scale_denom, layer_min_scale_denom - a scale range in format 1 : 10 000
        • item_type - may be group or layer
        • display_name - layer or group name
        • layer_style_id - vector or raster layer style resource identificator
        • layer_transparency - transparency
        • group_expanded - is group checked by default or not
  • basemap_webmap - array of web map basemaps

    • opacity - basemap opacity
    • enabled - is basemap should be present in web map basemaps combobox
    • position - position in web map basemaps combobox
    • display_name - name showing in web map basemaps combobox
    • resource_id - basemap resource identificator
  • resmeta - resource metadata

5.1.2.3.8. Feature count

To get feature count in vector layer execute the following request:

GET /api/resource/(int: id)/feature_count

Get feature count

Request Headers:
 
Status Codes:

Example request:

GET /api/resoure/10/feature_count HTTP/1.1
Host: ngw_url
Accept: */*

Example response:

{
  "total_count": 0
}

5.1.2.3.9. Get layer extent

To get layer extent execute following request. You can request extent for vector and raster layers. Returned coordinates are in WGS84 (EPSG:4326) spatial reference.

GET /api/resource/(int: id)/extent

Get layer extent

Request Headers:
 
Response JSON Object:
 
  • extent (jsonobj) – extent json object
Status Codes:

Example request:

GET /api/resoure/10/extent HTTP/1.1
Host: ngw_url
Accept: */*

Example response:

{
  "extent":
  {
    "minLat": 54.760400119987466,
    "maxLon": 35.08562149737197,
    "minLon": 35.06675807847286,
    "maxLat": 54.768358305249386
  }
}

5.1.2.3.10. Feature

To get a single feature of vector layer execute the following request:

GET /api/resource/(int: id)/feature/(int: feature_id)

To get all vector layer features execute the following request:

GET /api/resource/(int: id)/feature/

Example request:

GET api/resource/1878/feature/8 HTTP/1.1
Host: ngw_url
Accept: */*

Example JSON response:

{
  "id": 8,
  "geom": "MULTIPOLYGON (((4071007.5456240694038570 7385427.4912760490551591,
                           4071010.5846461649052799 7385440.8649944914504886,
                           4071018.6441773008555174 7385439.0351102603599429,
                           4071019.4902054299600422 7385442.7727465946227312,
                           4071057.3388322992250323 7385434.1683989763259888,
                           4071056.4928041673265398 7385430.4307667789980769,
                           4071065.5208148718811572 7385428.1726148622110486,
                           4071062.6153761623427272 7385414.7794514624401927,
                           4071058.2961799190379679 7385415.5581231201067567,
                           4071055.1347063803113997 7385401.6588457319885492,
                           4071007.8795825401321054 7385412.3850365970283747,
                           4071011.1301116724498570 7385426.6931363716721535,
                           4071007.5456240694038570 7385427.4912760490551591)))",
  "fields": {
      "OSM_ID": 128383475,
      "BUILDING": "apartments",
      "A_STRT": "проспект Ленина",
      "A_SBRB": "",
      "A_HSNMBR": "209",
      "B_LEVELS": "14",
      "NAME": ""
  }
}

Example response with photo and description:

{
     "id": 1,
     "geom": "MULTIPOINT (14690369.3387846201658249 5325725.3689366327598691)",
     "fields": {
         "name_official": "Краевое государственное автономное учреждение...",
         "name_short": "МФЦ Приморского края",
         "square": "702",
         "windows": "16",
         "start_date": "2013/12/30",
         "addr": "690080, Приморский край. г. Владивосток, ул. Борисенко д. 102",
         "phone_consult": "(423) 201-01-56",
         "opening_hours": "пн: 09:00-18:00 (по предварительной записи)вт: 09:00-20:00ср: 11:00-20:00чт: 09:00-20:00пт: 09:00-20:00 сб: 09:00-13:00 вс: выходной",
         "director": "Александров Сергей Валерьевич",
         "desc": "Центр создан в целях ...",
         "services_info": "Ознакомиться с перечнем можно ...",
         "issue_info": "ответственность должностных лиц ...",
         "website": "http://mfc-25.ru"
       },
     "extensions": {
         "description": " Описание объекта в ...",
         "attachment": [
             {
                 "id": 1,
                 "name": "fyADeqvXtXo.jpg",
                 "size": 107458,
                 "mime_type": "image/jpeg",
                 "description": null,
                 "is_image": true
             },
             {
                 "id": 2,
                 "name": "0_12cb49_b02b5fb0_orig.jpg",
                 "size": 65121,
                 "mime_type": "image/jpeg",
                 "description": "Текст подписи к фото",
                 "is_image": true
             }
         ]
     }
 }

5.1.2.3.11. Attachment

Attachment URL forms from feature URL adding attachment/ and attachment identificator. For example:

GET /api/resource/(int: id)/feature/(int: feature_id)/attachment/(int: attachment_id)/download

Attachment support loading any file types. For image files a preview generates during upload.

GET /api/resource/(int: id)/feature/(int: feature_id)/attachment/(int: attachment_id)/image?size=200x150

5.1.2.3.12. Map web interface

New in version 3.0.

To get map web interface (not a map json representation) execute one of the following request:

GET resource/{0}/display

Web map user interface.

Example request:

GET resource/42/display HTTP/1.1
Host: ngw_url
Accept: */*

To get web interface without layer control and toolbars execute the following request:

GET resource/{0}/display/tiny

Web map light user interface.