Coverage for gws-app/gws/base/edit/api.py: 100%
46 statements
« prev ^ index » next coverage.py v7.16.2, created at 2026-10-05 13:35 +0200
« prev ^ index » next coverage.py v7.16.2, created at 2026-10-05 13:35 +0200
1"""Request and response types of the edit API."""
3from typing import Optional
5import gws
6import gws.lib.mime
9class GetModelsRequest(gws.Request):
10 """Request for the editable models of a project."""
12 pass
15class GetModelsResponse(gws.Response):
16 """Editable models of a project."""
18 models: list[gws.ext.props.model]
19 """Model props."""
22class GetFeaturesRequest(gws.Request):
23 """Request for features of editable models."""
25 modelUids: list[str]
26 """Uids of the models to search."""
27 crs: Optional[gws.CrsName]
28 """CRS of ``extent``, the project map CRS by default."""
29 extent: Optional[gws.Extent]
30 """Search extent."""
31 featureUids: Optional[list[str]]
32 """Return only features with these uids."""
33 keyword: Optional[str]
34 """Search keyword."""
35 resolution: Optional[float]
36 """Map resolution."""
37 shapes: Optional[list[gws.ShapeProps]]
38 """Search shapes, combined into one."""
39 tolerance: Optional[str]
40 """Search tolerance. Not used, the helper applies a fixed tolerance of 10 pixels."""
43class GetFeaturesResponse(gws.Response):
44 """Features of editable models."""
46 features: list[gws.FeatureProps]
47 """Feature props."""
50class GetRelatableFeaturesRequest(gws.Request):
51 """Request for features that can be linked in a related field."""
53 modelUid: str
54 """Uid of the model that has the field."""
55 fieldName: str
56 """Name of the related field."""
57 extent: Optional[gws.Extent]
58 """Search extent. Not used."""
59 keyword: Optional[str]
60 """Search keyword."""
63class GetRelatableFeaturesResponse(gws.Response):
64 """Features that can be linked in a related field."""
66 features: list[gws.FeatureProps]
67 """Feature props."""
70class GetFeatureRequest(gws.Request):
71 """Request for a single feature."""
73 modelUid: str
74 """Model uid."""
75 featureUid: str
76 """Feature uid."""
79class GetFeatureResponse(gws.Response):
80 """A single feature."""
82 feature: gws.FeatureProps
83 """Feature props."""
86class InitFeatureRequest(gws.Request):
87 """Request to initialize a new feature."""
89 modelUid: str
90 """Model uid."""
91 feature: gws.FeatureProps
92 """Props of the new feature."""
95class InitFeatureResponse(gws.Response):
96 """A new feature with initial values."""
98 feature: gws.FeatureProps
99 """Feature props."""
102class WriteFeatureRequest(gws.Request):
103 """Request to save a new or existing feature."""
105 modelUid: str
106 """Model uid."""
107 feature: gws.FeatureProps
108 """Feature props. ``isNew`` decides between create and update."""
111class WriteFeatureResponse(gws.Response):
112 """Result of saving a feature."""
114 validationErrors: list[gws.ModelValidationError]
115 """Validation errors. If not empty, the feature was not saved."""
116 feature: gws.FeatureProps
117 """The saved feature, read back from the model."""
120class DeleteFeatureRequest(gws.Request):
121 """Request to delete a feature."""
123 modelUid: str
124 """Model uid."""
125 feature: gws.FeatureProps
126 """Props of the feature to delete."""
129class DeleteFeatureResponse(gws.Response):
130 """Result of deleting a feature."""
132 pass