@@ -521,7 +521,7 @@ async def update_organization_acl(
521521
522522async def list_json_schemas (
523523 organization_name : str , * , synapse_client : Optional ["Synapse" ] = None
524- ) -> List [Dict [str , Any ]]:
524+ ) -> AsyncGenerator [Dict [str , Any ], None ]:
525525 """
526526 List all JSON schemas for an organization.
527527
@@ -535,7 +535,7 @@ async def list_json_schemas(
535535 instance from the Synapse class constructor
536536
537537 Returns:
538- A list of JsonSchemaInfo objects, each containing:
538+ A generator of JsonSchemaInfo objects, each containing:
539539 - organizationId: The Synapse issued numeric identifier for the organization.
540540 - organizationName: The name of the organization to which this schema belongs.
541541 - schemaId: The Synapse issued numeric identifier for the schema.
@@ -549,22 +549,52 @@ async def list_json_schemas(
549549
550550 request_body = {"organizationName" : organization_name }
551551
552- results = []
553-
554552 async for item in rest_post_paginated_async (
555553 "/schema/list" , body = request_body , synapse_client = client
556554 ):
557- results . append ( item )
555+ yield item
558556
559- return results
557+
558+ def list_json_schemas_sync (
559+ organization_name : str , * , synapse_client : Optional ["Synapse" ] = None
560+ ) -> Generator [Dict [str , Any ], None , None ]:
561+ """
562+ List all JSON schemas for an organization.
563+
564+ Retrieves all JSON schemas that belong to the specified organization. This operation
565+ does not require authentication and will return all publicly visible schemas.
566+
567+ Arguments:
568+ organization_name: The name of the organization to list schemas for
569+ synapse_client: If not passed in and caching was not disabled by
570+ `Synapse.allow_client_caching(False)` this will use the last created
571+ instance from the Synapse class constructor
572+
573+ Returns:
574+ A generator of JsonSchemaInfo objects, each containing:
575+ - organizationId: The Synapse issued numeric identifier for the organization.
576+ - organizationName: The name of the organization to which this schema belongs.
577+ - schemaId: The Synapse issued numeric identifier for the schema.
578+ - schemaName: The name of the this schema.
579+ - createdOn: The date this JSON schema was created.
580+ - createdBy: The ID of the user that created this JSON schema.
581+ """
582+ from synapseclient import Synapse
583+
584+ client = Synapse .get_client (synapse_client = synapse_client )
585+
586+ request_body = {"organizationName" : organization_name }
587+
588+ for item in client ._POST_paginated ("/schema/list" , body = request_body ):
589+ yield item
560590
561591
562592async def list_json_schema_versions (
563593 organization_name : str ,
564594 json_schema_name : str ,
565595 * ,
566596 synapse_client : Optional ["Synapse" ] = None ,
567- ) -> List [Dict [str , Any ]]:
597+ ) -> AsyncGenerator [Dict [str , Any ], None ]:
568598 """
569599 List version information for a JSON schema.
570600
@@ -579,7 +609,52 @@ async def list_json_schema_versions(
579609 instance from the Synapse class constructor
580610
581611 Returns:
582- A list of JsonSchemaVersionInfo objects, each containing:
612+ A generator of JsonSchemaVersionInfo objects, each containing:
613+ - organizationId: The Synapse issued numeric identifier for the organization.
614+ - organizationName: The name of the organization to which this schema belongs.
615+ - schemaName: The name of the this schema.
616+ - schemaId: The Synapse issued numeric identifier for the schema.
617+ - versionId: The Synapse issued numeric identifier for this version.
618+ - $id: The full '$id' of this schema version
619+ - semanticVersion: The semantic version label provided when this version was created. Can be null if a semantic version was not provided when this version was created.
620+ - createdOn: The date this JSON schema version was created.
621+ - createdBy: The ID of the user that created this JSON schema version.
622+ - jsonSHA256Hex: The SHA-256 hexadecimal hash of the UTF-8 encoded JSON schema.
623+
624+ Object matching <https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/schema/JsonSchemaVersionInfo.html>
625+ """
626+ request_body = {
627+ "organizationName" : organization_name ,
628+ "schemaName" : json_schema_name ,
629+ }
630+
631+ async for item in rest_post_paginated_async (
632+ "/schema/version/list" , body = request_body , synapse_client = synapse_client
633+ ):
634+ yield item
635+
636+
637+ def list_json_schema_versions_sync (
638+ organization_name : str ,
639+ json_schema_name : str ,
640+ * ,
641+ synapse_client : Optional ["Synapse" ] = None ,
642+ ) -> Generator [Dict [str , Any ], None , None ]:
643+ """
644+ List version information for a JSON schema.
645+
646+ Retrieves version information for all versions of the specified JSON schema within
647+ an organization. This shows the history and available versions of a schema.
648+
649+ Arguments:
650+ organization_name: The name of the organization containing the schema
651+ json_schema_name: The name of the JSON schema to list versions for
652+ synapse_client: If not passed in and caching was not disabled by
653+ `Synapse.allow_client_caching(False)` this will use the last created
654+ instance from the Synapse class constructor
655+
656+ Returns:
657+ A generator of JsonSchemaVersionInfo objects, each containing:
583658 - organizationId: The Synapse issued numeric identifier for the organization.
584659 - organizationName: The name of the organization to which this schema belongs.
585660 - schemaName: The name of the this schema.
@@ -602,14 +677,8 @@ async def list_json_schema_versions(
602677 "schemaName" : json_schema_name ,
603678 }
604679
605- results = []
606-
607- async for item in rest_post_paginated_async (
608- "/schema/version/list" , body = request_body , synapse_client = client
609- ):
610- results .append (item )
611-
612- return results
680+ for item in client ._POST_paginated ("/schema/version/list" , body = request_body ):
681+ yield item
613682
614683
615684async def get_json_schema_body (
0 commit comments