glean-indexing-sdk 0.0.3__py3-none-any.whl → 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -53,4 +53,4 @@ __all__ = [
53
53
  try:
54
54
  __version__ = version("glean-indexing-sdk")
55
55
  except PackageNotFoundError:
56
- __version__ = "0.0.3"
56
+ __version__ = "0.1.0"
@@ -0,0 +1,115 @@
1
+ from typing import List, Optional
2
+
3
+ from glean.api_client.models.propertydefinition import PropertyDefinition, PropertyType, UIOptions
4
+
5
+
6
+ class PropertyDefinitionBuilder:
7
+ """
8
+ Builder class for creating PropertyDefinition objects with a fluent interface.
9
+
10
+ This class provides a convenient way to build multiple PropertyDefinition objects
11
+ with proper validation and type safety.
12
+
13
+ Example:
14
+ builder = PropertyDefinitionBuilder()
15
+ properties = (builder
16
+ .add_property("title", "Title", property_type=PropertyType.TEXT)
17
+ .add_property("author", "Author", display_label_plural="Authors")
18
+ .build())
19
+ """
20
+
21
+ def __init__(self) -> None:
22
+ self.properties: List[PropertyDefinition] = []
23
+
24
+ def add_property(
25
+ self,
26
+ name: str,
27
+ display_label: str,
28
+ display_label_plural: Optional[str] = None,
29
+ property_type: PropertyType = PropertyType.TEXT,
30
+ ui_options: UIOptions = UIOptions.SEARCH_RESULT,
31
+ hide_ui_facet: bool = False,
32
+ ui_facet_order: Optional[int] = None,
33
+ group: Optional[str] = None,
34
+ ) -> "PropertyDefinitionBuilder":
35
+ """
36
+ Add a property definition to the builder.
37
+
38
+ Args:
39
+ name: The property name (must not be empty)
40
+ display_label: The display label for the property
41
+ display_label_plural: Optional plural form of the display label
42
+ property_type: The type of property (defaults to TEXT)
43
+ ui_options: UI options for the property (defaults to SEARCH_RESULT)
44
+ hide_ui_facet: Whether to hide the UI facet
45
+ ui_facet_order: Optional order for UI facet display
46
+ group: Optional group name for the property
47
+
48
+ Returns:
49
+ Self for method chaining
50
+
51
+ Raises:
52
+ ValueError: If name or display_label is empty
53
+ """
54
+ if not name or not name.strip():
55
+ raise ValueError("Property name cannot be empty")
56
+ if not display_label or not display_label.strip():
57
+ raise ValueError("Display label cannot be empty")
58
+
59
+ base_params = {
60
+ "name": name.strip(),
61
+ "display_label": display_label.strip(),
62
+ "property_type": property_type.value,
63
+ "ui_options": ui_options.value,
64
+ "hide_ui_facet": hide_ui_facet,
65
+ }
66
+
67
+ optional_params = {
68
+ k: v
69
+ for k, v in {
70
+ "display_label_plural": display_label_plural.strip()
71
+ if display_label_plural
72
+ else None,
73
+ "ui_facet_order": ui_facet_order,
74
+ "group": group.strip() if group else None,
75
+ }.items()
76
+ if v is not None
77
+ }
78
+
79
+ params = {**base_params, **optional_params}
80
+
81
+ try:
82
+ prop = PropertyDefinition(**params)
83
+ self.properties.append(prop)
84
+ except Exception as e:
85
+ raise ValueError(f"Failed to create PropertyDefinition: {e}") from e
86
+
87
+ return self
88
+
89
+ def clear(self) -> "PropertyDefinitionBuilder":
90
+ """
91
+ Clear all properties from the builder.
92
+
93
+ Returns:
94
+ Self for method chaining
95
+ """
96
+ self.properties.clear()
97
+ return self
98
+
99
+ def count(self) -> int:
100
+ """
101
+ Get the number of properties currently in the builder.
102
+
103
+ Returns:
104
+ Number of properties
105
+ """
106
+ return len(self.properties)
107
+
108
+ def build(self) -> List[PropertyDefinition]:
109
+ """
110
+ Build and return the list of PropertyDefinition objects.
111
+
112
+ Returns:
113
+ List of PropertyDefinition objects
114
+ """
115
+ return self.properties.copy()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: glean-indexing-sdk
3
- Version: 0.0.3
3
+ Version: 0.1.0
4
4
  Summary: SDK for building custom Glean indexing integrations
5
5
  Project-URL: Source Code, https://github.com/glean-io/glean-indexing-sdk
6
6
  Author-email: Steve Calvert <steve.calvert@glean.com>
@@ -1,4 +1,4 @@
1
- glean/indexing/__init__.py,sha256=4rk3Q9mlKf707DNKstmOf2l5cljagvYobwwHhYlD-Zw,1519
1
+ glean/indexing/__init__.py,sha256=pYmCWpPddpoOR3fGN2ex8wjcQM4PHF8VM1ylmeHfxZY,1519
2
2
  glean/indexing/models.py,sha256=UuaEDCx0ygvU4u0lRbSn4YXXZVo7D_pyD_whQtjORm8,1223
3
3
  glean/indexing/py.typed,sha256=Nqnn8clbgv-5l0PgxcTOldg8mkMKrFn4TvPL-rYUUGg,1
4
4
  glean/indexing/common/__init__.py,sha256=6COS3jP66xJ7VcNGI8I95tkF5zpqHy9QPVn82CB4m4I,513
@@ -7,6 +7,7 @@ glean/indexing/common/content_formatter.py,sha256=PkIUZRoRtaOf1w6tJbB3cDj4oV58I7
7
7
  glean/indexing/common/glean_client.py,sha256=tKRWK_C1Nja0gVy2FLnj9SmUbpIdOA3WKmpuuhIl7kk,488
8
8
  glean/indexing/common/metrics.py,sha256=SWCWCYnNOkN4cnwCxyWyEF8iHVwQ4HZqhewi2lqyS84,1771
9
9
  glean/indexing/common/mocks.py,sha256=-TbLzpZ7yUstQW58AICixiIQM2CV5_OPRXejjI_brhE,726
10
+ glean/indexing/common/property_definition_builder.py,sha256=NZFhSqsSZlhI0Ia76sn0meYr82msBMCKMd78zMKLWAM,3724
10
11
  glean/indexing/connectors/__init__.py,sha256=YaHEmCj246zKIvPIAOjTBTDV2O-KvMLncc6jjmaEeOw,1035
11
12
  glean/indexing/connectors/base_connector.py,sha256=Q435TzSLqs0OTFBrD3KCcjQnGSICQg11pdSfJ7C3XtI,2398
12
13
  glean/indexing/connectors/base_data_client.py,sha256=krOFHJbwCZI-hCS6fr-z44TvjCbPCTCw54hkk0CZFsQ,1004
@@ -21,7 +22,7 @@ glean/indexing/testing/connector_test_harness.py,sha256=CMQZmn0cOIrj_GdIHb3OwRN9
21
22
  glean/indexing/testing/mock_data_source.py,sha256=ICYbbHQZe9RVTzvrlwcxp_suxm9yXgjEAGiNCU-SkS4,1325
22
23
  glean/indexing/testing/mock_glean_client.py,sha256=aY_Jfg_NJNPw2HSM1IshgT2lkT59SD9BJzOnvNFJhck,2528
23
24
  glean/indexing/testing/response_validator.py,sha256=jehEtXlW0AQcOVck-_VPoDFtQM_vkHJQ10SUN1ftr1Q,1800
24
- glean_indexing_sdk-0.0.3.dist-info/METADATA,sha256=uyukc_HxjJuhdYzolllnxL8tqpmyWani9g1_NVJhnI4,15619
25
- glean_indexing_sdk-0.0.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
26
- glean_indexing_sdk-0.0.3.dist-info/licenses/LICENSE,sha256=RAfePGwatR5BOtlNhW60zAKWCeHVgtGpaGBqZQadXNQ,1062
27
- glean_indexing_sdk-0.0.3.dist-info/RECORD,,
25
+ glean_indexing_sdk-0.1.0.dist-info/METADATA,sha256=Y5J0IXw5FzP6k_Ao7AlU7RGPgW3Jom1noJMZDU8gHYw,15619
26
+ glean_indexing_sdk-0.1.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
27
+ glean_indexing_sdk-0.1.0.dist-info/licenses/LICENSE,sha256=RAfePGwatR5BOtlNhW60zAKWCeHVgtGpaGBqZQadXNQ,1062
28
+ glean_indexing_sdk-0.1.0.dist-info/RECORD,,