@@ -638,17 +638,23 @@ def store(
638638 """
639639 return self
640640
641- def delete (self ) -> None :
641+ def delete (
642+ self , version : Optional [str ] = None , synapse_client : Optional ["Synapse" ] = None
643+ ) -> None :
642644 """
643645 Deletes this JSONSchema
644646
645647 Arguments:
648+ version: Defaults to None.
649+ - If a version is supplied, that version will be deleted.
650+ - If no version is supplied the whole schema will be deleted.
646651 synapse_client: If not passed in and caching was not disabled by
647652 `Synapse.allow_client_caching(False)` this will use the last created
648653 instance from the Synapse class constructor
649654
650- Example: Delete this JSONSchema from Synapse
651-
655+ Example: Delete from Synapse
656+
657+ Delete the entire schema
652658
653659 ```python
654660 from synapseclient.models import JSONSchema
@@ -660,6 +666,19 @@ def delete(self) -> None:
660666 js = JSONSchema("my.schema.name", "my.org.name")
661667 js.delete()
662668 ```
669+
670+ Delete a specific version from Synapse
671+
672+ ```python
673+ from synapseclient.models import JSONSchema
674+ from synapseclient import Synapse
675+
676+ syn = Synapse()
677+ syn.login()
678+
679+ js = JSONSchema("my.schema.name", "my.org.name")
680+ js.delete(version="0.0.1")
681+ ```
663682 """
664683 return None
665684
@@ -750,7 +769,7 @@ class JSONSchema(JSONSchemaProtocol):
750769 id: The ID of the schema
751770 created_on: The date this schema was created
752771 created_by: The ID of the user that created this schema
753- uri: The uri of this schema
772+ uri: The schema identifier in format: <organization_name>-<schema_name>
754773 """
755774
756775 name : Optional [str ] = None
@@ -772,7 +791,7 @@ class JSONSchema(JSONSchemaProtocol):
772791 """The ID of the user that created this schema"""
773792
774793 uri : Optional [str ] = field (init = False )
775- """The uri of this schema """
794+ """The schema identifier in format: <organization_name>-<schema_name> """
776795
777796 def __post_init__ (self ) -> None :
778797 if self .name :
@@ -883,7 +902,20 @@ async def store_schema():
883902 syn.login()
884903
885904 schema = JSONSchema(organization_name="my.org", name="test.schema")
886- await schema.store_async(schema_body = {})
905+ schema_body = {
906+ {
907+ "properties": {
908+ "Component": {
909+ "description": "TBD",
910+ "not": {
911+ "type": "null"
912+ },
913+ "title": "Component"
914+ }
915+ }
916+ }
917+ }
918+ await schema.store_async(schema_body = schema_body)
887919
888920 asyncio.run(store_schema())
889921 ```
@@ -910,17 +942,24 @@ async def store_schema():
910942 self .created_on = new_version_info .created_on
911943 return self
912944
913- async def delete_async (self , synapse_client : Optional ["Synapse" ] = None ) -> None :
945+ async def delete_async (
946+ self , version : Optional [str ] = None , synapse_client : Optional ["Synapse" ] = None
947+ ) -> None :
914948 """
915- Deletes this JSONSchema from Synapse
949+ If a version is supplied the specific version is deleted from Synapse.
950+ Otherwise the entire schema is deleted from Synapse
916951
917952 Arguments:
953+ version: Defaults to None.
954+ - If a version is supplied, that version will be deleted.
955+ - If no version is supplied the whole schema will be deleted.
918956 synapse_client: If not passed in and caching was not disabled by
919957 `Synapse.allow_client_caching(False)` this will use the last created
920958 instance from the Synapse class constructor
921959
922960 Example: Delete an existing JSONSchema
923-
961+
962+ Delete the whole schema
924963
925964 ```python
926965 from synapseclient.models import JSONSchema
@@ -933,7 +972,25 @@ async def delete_schema():
933972 syn.login()
934973
935974 schema = JSONSchema(organization_name="my.org", name="test.schema")
936- await schema.delete_async(schema_body = {})
975+ await schema.delete_async()
976+
977+ asyncio.run(delete_schema())
978+ ```
979+
980+ Delete a specific version of the schema
981+
982+ ```python
983+ from synapseclient.models import JSONSchema
984+ from synapseclient import Synapse
985+ import asyncio
986+
987+ async def delete_schema():
988+
989+ syn = Synapse()
990+ syn.login()
991+
992+ schema = JSONSchema(organization_name="my.org", name="test.schema")
993+ await schema.delete_async(version = "0.0.1")
937994
938995 asyncio.run(delete_schema())
939996 ```
@@ -943,7 +1000,12 @@ async def delete_schema():
9431000 if not self .organization_name :
9441001 raise ValueError ("JSONSchema must have a organization_name" )
9451002
946- await delete_json_schema (self .uri , synapse_client = synapse_client )
1003+ uri = self .uri
1004+ if version :
1005+ self ._check_semantic_version (version )
1006+ uri = f"{ uri } -{ version } "
1007+
1008+ await delete_json_schema (uri , synapse_client = synapse_client )
9471009
9481010 @skip_async_to_sync
9491011 async def get_versions_async (
0 commit comments