8
8
9
9
10
10
class PropertyValuesQuery (SearchQuery , total = False ):
11
- """Extended SearchQuery for property values endpoint with text search support."""
11
+ """Extended SearchQuery for property values endpoint with text search support.
12
+
13
+ This class extends the base SearchQuery to include additional search capabilities
14
+ specifically for querying property values, including text-based search functionality.
15
+
16
+ Attributes:
17
+ query (Optional[str]): Text search string to filter property values.
18
+ When provided, performs a text-based search among the property values.
19
+ """
12
20
13
21
query : Optional [str ] # For text search among values
14
22
15
23
16
24
class PropertiesAPI (BaseAPI ):
17
- """API for managing properties in RushDB."""
25
+ """API client for managing properties in RushDB.
26
+
27
+ The PropertiesAPI provides functionality for working with database properties,
28
+ including searching for properties, retrieving individual properties by ID,
29
+ deleting properties, and querying property values. Properties represent
30
+ metadata about the structure and characteristics of data in the database.
31
+
32
+ This class handles:
33
+ - Property discovery and searching
34
+ - Individual property retrieval
35
+ - Property deletion
36
+ - Property values querying with text search capabilities
37
+ - Transaction support for all operations
38
+
39
+ Attributes:
40
+ client: The underlying RushDB client instance for making HTTP requests.
41
+
42
+ Example:
43
+ >>> from rushdb import RushDB
44
+ >>> client = RushDB(api_key="your_api_key")
45
+ >>> properties_api = client.properties
46
+ >>>
47
+ >>> # Find all properties
48
+ >>> properties = properties_api.find()
49
+ >>>
50
+ >>> # Get a specific property
51
+ >>> property_obj = properties_api.find_by_id("property_123")
52
+ """
18
53
19
54
def find (
20
55
self ,
21
56
search_query : Optional [SearchQuery ] = None ,
22
57
transaction : Optional [Transaction ] = None ,
23
58
) -> List [Property ]:
24
- """List all properties."""
59
+ """Search for and retrieve properties matching the specified criteria.
60
+
61
+ Searches the database for properties that match the provided search query.
62
+ Properties represent metadata about the database structure and can be
63
+ filtered using various search criteria.
64
+
65
+ Args:
66
+ search_query (Optional[SearchQuery], optional): The search criteria to filter properties.
67
+ If None, returns all properties. Can include filters for property names,
68
+ types, or other metadata. Defaults to None.
69
+ transaction (Optional[Transaction], optional): Transaction context for the operation.
70
+ If provided, the operation will be part of the transaction. Defaults to None.
71
+
72
+ Returns:
73
+ List[Property]: List of Property objects matching the search criteria.
74
+
75
+ Raises:
76
+ RequestError: If the server request fails.
77
+
78
+ Example:
79
+ >>> from rushdb.models.search_query import SearchQuery
80
+ >>> properties_api = PropertiesAPI(client)
81
+ >>>
82
+ >>> # Find all properties
83
+ >>> all_properties = properties_api.find()
84
+ >>>
85
+ >>> # Find properties with specific criteria
86
+ >>> query = SearchQuery(where={"age":{"$gte": 30}})
87
+ >>> string_properties = properties_api.find(query)
88
+ """
25
89
headers = Transaction ._build_transaction_header (transaction )
26
90
27
91
return self .client ._make_request (
@@ -34,7 +98,29 @@ def find(
34
98
def find_by_id (
35
99
self , property_id : str , transaction : Optional [Transaction ] = None
36
100
) -> Property :
37
- """Get a property by ID."""
101
+ """Retrieve a specific property by its unique identifier.
102
+
103
+ Fetches a single property from the database using its unique ID.
104
+ This method is useful when you know the exact property you want to retrieve.
105
+
106
+ Args:
107
+ property_id (str): The unique identifier of the property to retrieve.
108
+ transaction (Optional[Transaction], optional): Transaction context for the operation.
109
+ If provided, the operation will be part of the transaction. Defaults to None.
110
+
111
+ Returns:
112
+ Property: The Property object with the specified ID.
113
+
114
+ Raises:
115
+ ValueError: If the property_id is invalid or empty.
116
+ NotFoundError: If no property exists with the specified ID.
117
+ RequestError: If the server request fails.
118
+
119
+ Example:
120
+ >>> properties_api = PropertiesAPI(client)
121
+ >>> property_obj = properties_api.find_by_id("prop_123")
122
+ >>> print(property_obj.name)
123
+ """
38
124
headers = Transaction ._build_transaction_header (transaction )
39
125
40
126
return self .client ._make_request (
@@ -44,7 +130,33 @@ def find_by_id(
44
130
def delete (
45
131
self , property_id : str , transaction : Optional [Transaction ] = None
46
132
) -> None :
47
- """Delete a property."""
133
+ """Delete a property from the database.
134
+
135
+ Permanently removes a property and all its associated metadata from the database.
136
+ This operation cannot be undone, so use with caution.
137
+
138
+ Args:
139
+ property_id (str): The unique identifier of the property to delete.
140
+ transaction (Optional[Transaction], optional): Transaction context for the operation.
141
+ If provided, the operation will be part of the transaction. Defaults to None.
142
+
143
+ Returns:
144
+ None: This method does not return a value.
145
+
146
+ Raises:
147
+ ValueError: If the property_id is invalid or empty.
148
+ NotFoundError: If no property exists with the specified ID.
149
+ RequestError: If the server request fails.
150
+
151
+ Warning:
152
+ This operation permanently deletes the property and cannot be undone.
153
+ Ensure you have proper backups and confirmation before deleting properties.
154
+
155
+ Example:
156
+ >>> properties_api = PropertiesAPI(client)
157
+ >>> properties_api.delete("prop_123")
158
+ >>> # Property is now permanently deleted
159
+ """
48
160
headers = Transaction ._build_transaction_header (transaction )
49
161
50
162
return self .client ._make_request (
@@ -57,7 +169,42 @@ def values(
57
169
search_query : Optional [PropertyValuesQuery ] = None ,
58
170
transaction : Optional [Transaction ] = None ,
59
171
) -> PropertyValuesData :
60
- """Get values data for a property."""
172
+ """Retrieve and search values data for a specific property.
173
+
174
+ Gets statistical and analytical data about the values stored in a particular property,
175
+ including value distributions, counts, and other metadata. Supports text-based
176
+ searching within the property values.
177
+
178
+ Args:
179
+ property_id (str): The unique identifier of the property to analyze.
180
+ search_query (Optional[PropertyValuesQuery], optional): Extended search query
181
+ that supports text search among property values. Can include:
182
+ - Standard SearchQuery filters
183
+ - query (str): Text search string to filter values
184
+ Defaults to None.
185
+ transaction (Optional[Transaction], optional): Transaction context for the operation.
186
+ If provided, the operation will be part of the transaction. Defaults to None.
187
+
188
+ Returns:
189
+ PropertyValuesData: Object containing statistical and analytical data about
190
+ the property's values, including distributions, counts, and value samples.
191
+
192
+ Raises:
193
+ ValueError: If the property_id is invalid or empty.
194
+ NotFoundError: If no property exists with the specified ID.
195
+ RequestError: If the server request fails.
196
+
197
+ Example:
198
+ >>> properties_api = PropertiesAPI(client)
199
+ >>>
200
+ >>> # Get all values data for a property
201
+ >>> values_data = properties_api.values("prop_123")
202
+ >>> print(f"Total values: {values_data.total}")
203
+ >>>
204
+ >>> # Search for specific values
205
+ >>> query = PropertyValuesQuery(query="search_text")
206
+ >>> filtered_values = properties_api.values("prop_123", query)
207
+ """
61
208
headers = Transaction ._build_transaction_header (transaction )
62
209
63
210
return self .client ._make_request (
0 commit comments