1
1
import json
2
- from typing import TYPE_CHECKING , AsyncGenerator , Optional
2
+ from typing import (
3
+ TYPE_CHECKING ,
4
+ Any ,
5
+ AsyncGenerator ,
6
+ Dict ,
7
+ Generator ,
8
+ List ,
9
+ Optional ,
10
+ Union ,
11
+ )
3
12
4
13
from synapseclient .api .api_client import rest_post_paginated_async
5
14
6
15
if TYPE_CHECKING :
7
16
from synapseclient import Synapse
8
- from synapseclient .models .mixins import (
9
- InvalidJSONSchemaValidation ,
10
- JSONSchemaBinding ,
11
- JSONSchemaDerivedKeys ,
12
- JSONSchemaValidation ,
13
- JSONSchemaValidationStatistics ,
14
- )
15
17
16
18
17
19
async def bind_json_schema_to_entity (
@@ -20,8 +22,11 @@ async def bind_json_schema_to_entity(
20
22
* ,
21
23
enable_derived_annos : bool = False ,
22
24
synapse_client : Optional ["Synapse" ] = None ,
23
- ) -> "JSONSchemaBinding" :
24
- """Bind a JSON schema to an entity
25
+ ) -> Union [Dict [str , Any ], str ]:
26
+ """
27
+ <https://rest-docs.synapse.org/rest/PUT/entity/id/schema/binding.html>
28
+
29
+ Bind a JSON schema to an entity
25
30
26
31
Arguments:
27
32
synapse_id: Synapse Entity or Synapse Id
@@ -31,7 +36,7 @@ async def bind_json_schema_to_entity(
31
36
`Synapse.allow_client_caching(False)` this will use the last created
32
37
instance from the Synapse class constructor
33
38
Returns:
34
- A JSONSchemaBindingResponse object containing the details of the binding.
39
+ Object matching <https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/schema/JsonSchemaObjectBinding.html>
35
40
"""
36
41
from synapseclient import Synapse
37
42
@@ -48,8 +53,11 @@ async def bind_json_schema_to_entity(
48
53
49
54
async def get_json_schema_from_entity (
50
55
synapse_id : str , * , synapse_client : Optional ["Synapse" ] = None
51
- ) -> "JSONSchemaBinding" :
52
- """Get bound schema from entity
56
+ ) -> Union [Dict [str , Any ], str ]:
57
+ """
58
+ <https://rest-docs.synapse.org/rest/GET/entity/id/schema/binding.html>
59
+
60
+ Get bound schema from entity
53
61
54
62
Arguments:
55
63
synapse_id: Synapse Id
@@ -58,7 +66,7 @@ async def get_json_schema_from_entity(
58
66
instance from the Synapse class constructor
59
67
60
68
Returns:
61
- A JSONSchemaBindingResponse object containing the details of the binding.
69
+ Object matching <https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/schema/JsonSchemaObjectBinding.html>
62
70
"""
63
71
from synapseclient import Synapse
64
72
@@ -69,7 +77,11 @@ async def get_json_schema_from_entity(
69
77
async def delete_json_schema_from_entity (
70
78
synapse_id : str , * , synapse_client : Optional ["Synapse" ] = None
71
79
) -> None :
72
- """Delete bound schema from entity
80
+ """
81
+ <https://rest-docs.synapse.org/rest/DELETE/entity/id/schema/binding.html>
82
+
83
+ Delete bound schema from entity
84
+
73
85
Arguments:
74
86
synapse_id: Synapse Id
75
87
synapse_client: If not passed in and caching was not disabled by
@@ -84,16 +96,19 @@ async def delete_json_schema_from_entity(
84
96
85
97
async def validate_entity_with_json_schema (
86
98
synapse_id : str , * , synapse_client : Optional ["Synapse" ] = None
87
- ) -> "JSONSchemaValidation" :
88
- """Get validation results of an entity against bound JSON schema
99
+ ) -> Union [Dict [str , Union [str , bool ]], str ]:
100
+ """
101
+ <https://rest-docs.synapse.org/rest/GET/entity/id/schema/validation.html>
102
+
103
+ Get validation results of an entity against bound JSON schema
89
104
90
105
Arguments:
91
106
synapse_id: Synapse Id
92
107
synapse_client: If not passed in and caching was not disabled by
93
108
`Synapse.allow_client_caching(False)` this will use the last created
94
109
instance from the Synapse class constructor
95
110
Returns:
96
- A JSONSchemaValidationResponse object containing the validation results.
111
+ Object matching <https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/schema/ValidationResults.html>
97
112
"""
98
113
from synapseclient import Synapse
99
114
@@ -103,16 +118,21 @@ async def validate_entity_with_json_schema(
103
118
104
119
async def get_json_schema_validation_statistics (
105
120
synapse_id : str , * , synapse_client : Optional ["Synapse" ] = None
106
- ) -> "JSONSchemaValidationStatistics" :
107
- """Get the summary statistic of json schema validation results for
121
+ ) -> Dict [str , Union [str , int ]]:
122
+ """
123
+
124
+ <https://rest-docs.synapse.org/rest/GET/entity/id/schema/validation/statistics.html>
125
+
126
+ Get the summary statistic of json schema validation results for
108
127
a container entity
109
128
Arguments:
110
129
synapse_id: Synapse Id
111
130
synapse_client: If not passed in and caching was not disabled by
112
131
`Synapse.allow_client_caching(False)` this will use the last created
113
132
instance from the Synapse class constructor
114
133
115
- Returns: a JSONSchemaValidationStatisticsResponse object
134
+ Returns:
135
+ Object matching <https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/schema/ValidationSummaryStatistics.html>
116
136
"""
117
137
from synapseclient import Synapse
118
138
@@ -124,8 +144,12 @@ async def get_json_schema_validation_statistics(
124
144
125
145
async def get_invalid_json_schema_validation (
126
146
synapse_id : str , * , synapse_client : Optional ["Synapse" ] = None
127
- ) -> AsyncGenerator ["InvalidJSONSchemaValidation" , None ]:
128
- """Get a single page of invalid JSON schema validation results for a container Entity
147
+ ) -> AsyncGenerator [Dict [str , Any ], None ]:
148
+ """
149
+
150
+ <https://rest-docs.synapse.org/rest/POST/entity/id/schema/validation/invalid.html>
151
+
152
+ Get a single page of invalid JSON schema validation results for a container Entity
129
153
(Project or Folder).
130
154
131
155
Arguments:
@@ -134,7 +158,7 @@ async def get_invalid_json_schema_validation(
134
158
`Synapse.allow_client_caching(False)` this will use the last created
135
159
instance from the Synapse class constructor
136
160
Returns:
137
- An AsyncGenerator yielding InvalidJSONSchemaValidationResponse objects.
161
+ Object matching <https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/schema/ValidationResults.html>
138
162
"""
139
163
140
164
request_body = {"containerId" : synapse_id }
@@ -149,7 +173,22 @@ async def get_invalid_json_schema_validation(
149
173
150
174
def get_invalid_json_schema_validation_sync (
151
175
synapse_id : str , * , synapse_client : Optional ["Synapse" ] = None
152
- ):
176
+ ) -> Generator [Dict [str , Any ], None ]:
177
+ """
178
+
179
+ <https://rest-docs.synapse.org/rest/POST/entity/id/schema/validation/invalid.html>
180
+
181
+ Get a single page of invalid JSON schema validation results for a container Entity
182
+ (Project or Folder).
183
+
184
+ Arguments:
185
+ synapse_id: Synapse Id
186
+ synapse_client: If not passed in and caching was not disabled by
187
+ `Synapse.allow_client_caching(False)` this will use the last created
188
+ instance from the Synapse class constructor
189
+ Returns:
190
+ Object matching <https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/schema/ValidationResults.html>
191
+ """
153
192
request_body = {"containerId" : synapse_id }
154
193
response = synapse_client ._POST_paginated (
155
194
f"/entity/{ synapse_id } /schema/validation/invalid" , request_body
@@ -160,14 +199,17 @@ def get_invalid_json_schema_validation_sync(
160
199
161
200
async def get_json_schema_derived_keys (
162
201
synapse_id : str , * , synapse_client : Optional ["Synapse" ] = None
163
- ) -> "JSONSchemaDerivedKeys" :
164
- """Retrieve derived JSON schema keys for a given Synapse entity.
202
+ ) -> List [str ]:
203
+ """
204
+ <https://rest-docs.synapse.org/rest/GET/entity/id/derivedKeys.html>
205
+
206
+ Retrieve derived JSON schema keys for a given Synapse entity.
165
207
166
208
Arguments:
167
209
synapse_id (str): The Synapse ID of the entity for which to retrieve derived keys.
168
210
169
211
Returns:
170
- dict: JSONSchemaDerivedKeysResponse object containing the derived keys for the entity.
212
+ Object matching <https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/annotation/v2/Keys.html>
171
213
"""
172
214
from synapseclient import Synapse
173
215
0 commit comments