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

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. Not used, the helper applies a fixed tolerance of 10 pixels.""" 

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 extent: Optional[gws.Extent] 

58 """Search extent. Not used.""" 

59 keyword: Optional[str] 

60 """Search keyword.""" 

61 

62 

63class GetRelatableFeaturesResponse(gws.Response): 

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

65 

66 features: list[gws.FeatureProps] 

67 """Feature props.""" 

68 

69 

70class GetFeatureRequest(gws.Request): 

71 """Request for a single feature.""" 

72 

73 modelUid: str 

74 """Model uid.""" 

75 featureUid: str 

76 """Feature uid.""" 

77 

78 

79class GetFeatureResponse(gws.Response): 

80 """A single feature.""" 

81 

82 feature: gws.FeatureProps 

83 """Feature props.""" 

84 

85 

86class InitFeatureRequest(gws.Request): 

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

88 

89 modelUid: str 

90 """Model uid.""" 

91 feature: gws.FeatureProps 

92 """Props of the new feature.""" 

93 

94 

95class InitFeatureResponse(gws.Response): 

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

97 

98 feature: gws.FeatureProps 

99 """Feature props.""" 

100 

101 

102class WriteFeatureRequest(gws.Request): 

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

104 

105 modelUid: str 

106 """Model uid.""" 

107 feature: gws.FeatureProps 

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

109 

110 

111class WriteFeatureResponse(gws.Response): 

112 """Result of saving a feature.""" 

113 

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.""" 

118 

119 

120class DeleteFeatureRequest(gws.Request): 

121 """Request to delete a feature.""" 

122 

123 modelUid: str 

124 """Model uid.""" 

125 feature: gws.FeatureProps 

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

127 

128 

129class DeleteFeatureResponse(gws.Response): 

130 """Result of deleting a feature.""" 

131 

132 pass