10.1.5. Editing

Change resource

Execute following PUT request to change resource.

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

Change resource request

Request Headers:
 
Parameters:
  • parent_id – parent resource id
  • id – changing resource id
Request JSON Object:
 
  • resource (jsonobj) – resource JSON object
  • display_name (string) – resource new name
  • keyname (string) – resource new key
  • id (int) – resource id (cannot be changed)
  • description (string) – resource new description
Request JSON Array of Objects:
 
  • permissions – resource permissions array
Status Codes:

Example request:

PUT /resource/7/child/8 HTTP/1.1
Host: ngw_url
Accept: */*

{"resource":
   {
       "display_name":"test3",
       "keyname":"qw4",
       "parent":{"id":7},
       "permissions":[],
       "description":"rrr5"
    }
}

Примечание

Payload of change resource request is equal to create resource request payload. The request must be authorized.

Change file bucket resource

To change file bucket execute following PUT request:

PUT /api/resource/(int: id)

Change file bucket request.

Request Headers:
 
Parameters:
  • id – resource identificator
Request JSON Object:
 
  • resource (jsonobj) – resource JSON object
  • cls (string) – type (must be file_bucket, for a list of supported types see Resource classes)
  • parent (jsonobj) – parent resource json object
  • id (int) – parent resource identificator
  • display_name (string) – name
  • keyname (string) – key (optional)
  • description (string) – decription text, HTML supported (optional)
  • file_bucket (jsonobj) – file bucket JSON object
Request JSON Array of Objects:
 
  • files – array of files should present in bucket: present (which need to delete don’t include in array), also new files (upload response JSON object, files == upload_meta)
Status Codes:

Example request:

PUT /api/resource/22 HTTP/1.1
Host: ngw_url
Accept: */*

 {
   "file_bucket": {
     "files": [
       {
         "mime_type": "application/x-dbf",
         "name": "grunt_area_2_multipolygon.dbf",
         "size": 36607
       },
       {
         "mime_type": "application/x-esri-shape",
         "name": "grunt_area_2_multipolygon.shp",
         "size": 65132
       },
       {
         "mime_type": "application/x-esri-shape",
         "name": "grunt_area_2_multipolygon.shx",
         "size": 1324
       },
       {
         "id": "fb439bfa-1a63-cccc-957d-ae57bb5eb67b",
         "mime_type": "application/octet-stream",
         "name": "grunt area description.txt",
         "size": 50
       }
     ]
   },
   "resource": {
     "cls": "file_bucket",
     "description": "some new text",
     "display_name": "new grunt_area",
     "keyname": null,
     "parent": {
       "id": 0
     }
   }
 }

In this example, file grunt area description.txt will be added, files grunt_area_2_multipolygon.cpg, grunt_area_2_multipolygon.prj - deleted, and bucket name and description will be changed.

Change lookup table resource

To change flookup table execute following PUT request:

PUT /api/resource/(int: id)

Change lookup table request.

Request Headers:
 
Parameters:
  • id – resource identificator
Request JSON Object:
 
  • resource (jsonobj) – resource JSON object
  • cls (string) – type (must be lookup_table, for a list of supported types see Resource classes)
  • id (int) – parent resource identificator
  • display_name (string) – name
  • keyname (string) – key (optional)
  • description (string) – decription text, HTML supported (optional)
  • resmeta (jsonobj) – metadata JSON object. Key - value JSON object struct.
  • file_bucket – file bucket JSON object
  • lookup_table (jsonobj) – lookup table values JSON object. Key - value JSON object struct.
Status Codes:

Example request:

PUT /api/resource/22 HTTP/1.1
Host: ngw_url
Accept: */*

{
  "lookup_table": {
     "items": {
         "car": "Машина",
         "plane": "Самолет"
     }
  }
}

Same steps with curl:

$ curl --user "user:password" -H 'Accept: */*' -X PUT -d '{"lookup_table":
{"items":{"car":"Машина", "plane":"Самолет"}}}'
http://<ngw url>/api/resource/

Change feature

To change feature in vector layer execute following request:

PUT /api/resource/(int: layer_id)/feature/(int: feature_id)

Change feature request

Parameters:
  • layer_id – layer resource identificator
  • feature_id – feature identificator
Request Headers:
 
Request JSON Object:
 
  • geom (string) – geometry in WKT format (geometry type ans spatial reference must be corespondent to layer geometry type and spatial reference)
  • id (int) – feture identificator
Request JSON Array of Objects:
 
  • fields – attributes array in form of JSON field name - value object
Status Codes:

Example request:

PUT /api/resource/3/feature/1 HTTP/1.1
Host: ngw_url
Accept: */*

{
  "extensions": {
    "attachment": null,
    "description": null
  },
  "fields": {
    "Age": 1,
    "DateTr": {
      "day": 7,
      "month": 2,
      "year": 2015
    },
    "Davnost": 4,
    "Foto": 26,
    "Nomerp": 1,
    "Nomers": 1,
    "Samka": 0,
    "Sex": 3,
    "Sizeb": 0.0,
    "Sizef": 0.0,
    "Sizes": 9.19999980926514,
    "Snowdepth": 31,
    "Wher": "\u043b\u044b\u0436\u043d\u044f",
    "id01": 0
  },
  "geom": "MULTIPOINT (15112317.9207317382097244 6059092.3103669174015522)",
  "id": 1
}

In request payload add only change fields. Other fields will stay unchanged. Also geom field may be skipped.

To change features in batch mode use patch request.

PATCH /api/resource/(int: layer_id)/feature

Change features request

Parameters:
  • layer_id – layer resource identificator
Request Headers:
 
Request JSON Array of Objects:
 
  • geom (string) – geometry in WKT format (geometry type ans spatial reference must be corespondent to layer geometry type and spatial reference)
  • fields (jsonarr) – attributes array in form of JSON field name - value object
  • id (int) – feture identificator
Status Codes:

Request accept array of JSON objects. If feature identificator is not present in vector layer - feature will be created, else - changed. .. Метод принимает на вход список объектов, если у объекта передан id - то обновляется этот объект, а у которых не передан - те создаёт

Delete feature

To delete feature from vector layer execute following request:

DELETE /api/resource/(int: layer_id)/feature/(int: feature_id)

Delete feature request

Request Headers:
 
Parameters:
  • layer_id – resource identificator
  • feature_id – feature identificator
Status Codes:

Example request:

DELETE /api/resource/3/feature/1 HTTP/1.1
Host: ngw_url
Accept: */*

Delete all features

To delete all feature in vector layer execute following request:

DELETE /api/resource/(int: layer_id)/feature/

Delete features request

Request Headers:
 
Parameters:
  • layer_id – resource identificator
Status Codes:

Example request:

DELETE /api/resource/3/feature/ HTTP/1.1
Host: ngw_url
Accept: */*