Coverage for gws-app/gws/base/edit/api.py: 100%

45 statements  

« prev     ^ index     » next       coverage.py v7.17.0, created at 2026-10-23 20:06 +0200

1"""Request and response types of the edit API.""" 

2 

3from typing import Optional 

4 

5import gws 

6import gws.lib.mime 

7 

8 

9class GetModelsRequest(gws.Request): 

10 """Request for the editable models of a project.""" 

11 

12 pass 

13 

14 

15class GetModelsResponse(gws.Response): 

16 """Editable models of a project.""" 

17 

18 models: list[gws.ext.props.model] 

19 """Model props.""" 

20 

21 

22class GetFeaturesRequest(gws.Request): 

23 """Request for features of editable models.""" 

24 

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, e.g. ``10px`` or ``5m``. A number without a unit is in pixels. 10 pixels by default.""" 

41 

42 

43class GetFeaturesResponse(gws.Response): 

44 """Features of editable models.""" 

45 

46 features: list[gws.FeatureProps] 

47 """Feature props.""" 

48 

49 

50class GetRelatableFeaturesRequest(gws.Request): 

51 """Request for features that can be linked in a related field.""" 

52 

53 modelUid: str 

54 """Uid of the model that has the field.""" 

55 fieldName: str 

56 """Name of the related field.""" 

57 keyword: Optional[str] 

58 """Search keyword.""" 

59 

60 

61class GetRelatableFeaturesResponse(gws.Response): 

62 """Features that can be linked in a related field.""" 

63 

64 features: list[gws.FeatureProps] 

65 """Feature props.""" 

66 

67 

68class GetFeatureRequest(gws.Request): 

69 """Request for a single feature.""" 

70 

71 modelUid: str 

72 """Model uid.""" 

73 featureUid: str 

74 """Feature uid.""" 

75 

76 

77class GetFeatureResponse(gws.Response): 

78 """A single feature.""" 

79 

80 feature: gws.FeatureProps 

81 """Feature props.""" 

82 

83 

84class InitFeatureRequest(gws.Request): 

85 """Request to initialize a new feature.""" 

86 

87 modelUid: str 

88 """Model uid.""" 

89 feature: gws.FeatureProps 

90 """Props of the new feature.""" 

91 

92 

93class InitFeatureResponse(gws.Response): 

94 """A new feature with initial values.""" 

95 

96 feature: gws.FeatureProps 

97 """Feature props.""" 

98 

99 

100class WriteFeatureRequest(gws.Request): 

101 """Request to save a new or existing feature.""" 

102 

103 modelUid: str 

104 """Model uid.""" 

105 feature: gws.FeatureProps 

106 """Feature props. ``isNew`` decides between create and update.""" 

107 

108 

109class WriteFeatureResponse(gws.Response): 

110 """Result of saving a feature.""" 

111 

112 validationErrors: list[gws.ModelValidationError] 

113 """Validation errors. If not empty, the feature was not saved.""" 

114 feature: gws.FeatureProps 

115 """The saved feature, read back from the model.""" 

116 

117 

118class DeleteFeatureRequest(gws.Request): 

119 """Request to delete a feature.""" 

120 

121 modelUid: str 

122 """Model uid.""" 

123 feature: gws.FeatureProps 

124 """Props of the feature to delete.""" 

125 

126 

127class DeleteFeatureResponse(gws.Response): 

128 """Result of deleting a feature.""" 

129 

130 pass