Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions synapseclient/extensions/curator/schema_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@
from dataclasses import dataclass
from typing import List, Optional, Union

from deprecated import deprecated

from synapseclient import Synapse
from synapseclient.models import Table

Expand Down Expand Up @@ -120,6 +122,11 @@ class SchemaRegistryColumnConfig:
uri_column: str = "uri"


@deprecated(
version="4.15.0",
reason="To be removed in 5.0.0. Use the Organization and JSONSchema models "
"from synapseclient.models to find JSON schemas instead.",
)
def query_schema_registry(
synapse_client: Optional[Synapse] = None,
schema_registry_table_id: Optional[str] = None,
Expand All @@ -130,6 +137,29 @@ def query_schema_registry(
"""
Query the schema registry table to find schemas matching the provided filters.

**Deprecated:** This function will be removed in 5.0.0. Use
[Organization][synapseclient.models.Organization] and
[JSONSchema][synapseclient.models.JSONSchema] instead.

Example: Find JSON schemas with the Organization and JSONSchema models
 
Get the JSON schemas of an organization and the versions of a schema.
```python
from synapseclient import Synapse
from synapseclient.models import JSONSchema, Organization

syn = Synapse()
syn.login()

org = Organization(name="my.organization")
for schema in org.get_json_schemas():
print(schema.uri)

schema = JSONSchema(organization_name="my.organization", name="my.schema")
for version in schema.get_versions():
print(version.semantic_version)
```

This function searches the Synapse schema registry table for schemas that match
the provided filter parameters. Results are sorted by version in descending order
(newest first). The function supports any number of filter parameters as long as
Expand Down Expand Up @@ -357,6 +387,11 @@ def query_schema_registry(
return uri_list


@deprecated(
version="4.15.0",
reason="To be removed in 5.0.0. Use the Organization and JSONSchema models "
"from synapseclient.models to find JSON schemas instead.",
)
def get_latest_schema_uri(
synapse_client: Optional[Synapse] = None,
schema_registry_table_id: Optional[str] = None,
Expand All @@ -366,6 +401,29 @@ def get_latest_schema_uri(
"""
Get the URI of the latest schema version for the given filter criteria.

**Deprecated:** This function will be removed in 5.0.0. Use
[Organization][synapseclient.models.Organization] and
[JSONSchema][synapseclient.models.JSONSchema] instead.

Example: Find JSON schemas with the Organization and JSONSchema models
 
Get the JSON schemas of an organization and the versions of a schema.
```python
from synapseclient import Synapse
from synapseclient.models import JSONSchema, Organization

syn = Synapse()
syn.login()

org = Organization(name="my.organization")
for schema in org.get_json_schemas():
print(schema.uri)

schema = JSONSchema(organization_name="my.organization", name="my.schema")
for version in schema.get_versions():
print(version.semantic_version)
```

This function queries the schema registry and returns the URI of the most recent
version of the schema that matches the provided filter parameters. This is equivalent
to calling query_schema_registry with return_latest_only=True.
Expand Down
Loading