JSON Schema

Warning

This is a beta implementation and is subject to change. Use at your own risk.

class synapseclient.services.json_schema.JsonSchema(organization: synapseclient.services.json_schema.JsonSchemaOrganization, name: str)

Json schema response object

Parameters
create(json_schema_body: dict, semantic_version: Optional[str] = None, dry_run: bool = False)

Create JSON schema

Parameters
  • json_schema_body (dict) – JSON schema body

  • semantic_version (str, optional) – Version of JSON schema. Defaults to None.

  • dry_run (bool, optional) – Do not store to Synapse. Defaults to False.

get()

Get Json schema

list_versions()

List versions of the json schema

class synapseclient.services.json_schema.JsonSchemaOrganization(name: str)

Json Schema Organization

Parameters

name (str) – Name of JSON schema organization

create()

Create the JSON schema organization

create_json_schema(json_schema_body: dict, name: Optional[str] = None, semantic_version: Optional[str] = None, dry_run: bool = False)

Create JSON schema

Parameters
  • json_schema_body (dict) – JSON schema dict

  • name (str, optional) – Name of JSON schema. Defaults to None.

  • semantic_version (str, optional) – Version of JSON schema. Defaults to None.

  • dry_run (bool, optional) – Don’t store to Synapse. Defaults to False.

delete()

Delete the JSON schema organization

get()

Gets Json Schema organization

get_acl()

Get ACL of JSON schema organization

get_json_schema(json_schema_name: str, raw: bool = False)

Get JSON schema

Parameters
  • json_schema_name (str) – Name of JSON schema.

  • raw (bool, optional) – Return raw JSON schema. Default is False.

list_json_schemas()

List JSON schemas available from the organization

set_acl(principal_ids: Sequence[int], access_type: Sequence[str] = ('CHANGE_PERMISSIONS', 'DELETE', 'READ', 'CREATE', 'UPDATE'), etag: Optional[str] = None)

Set ACL of JSON schema organization

Parameters
  • principal_ids (list) – List of Synapse user or team ids.

  • access_type (list, optional) – Access control list. Defaults to [“CHANGE_PERMISSIONS”, “DELETE”, “READ”, “CREATE”, “UPDATE”].

  • etag (str, optional) – Etag. Defaults to None.

update_acl(principal_ids: Sequence[int], access_type: Sequence[str] = ('CHANGE_PERMISSIONS', 'DELETE', 'READ', 'CREATE', 'UPDATE'), etag: Optional[str] = None)

Update ACL of JSON schema organization

Parameters
  • principal_ids (list) – List of Synapse user or team ids.

  • access_type (list, optional) – Access control list. Defaults to [“CHANGE_PERMISSIONS”, “DELETE”, “READ”, “CREATE”, “UPDATE”].

  • etag (str, optional) – Etag. Defaults to None.

class synapseclient.services.json_schema.JsonSchemaService(synapse: Optional[synapseclient.client.Synapse] = None)

Json Schema Service

Parameters

synapse (Synapse) – Synapse connection

JsonSchema = <function JsonSchema>
JsonSchemaOrganization = <function JsonSchemaOrganization>
JsonSchemaVersion = <function JsonSchemaVersion>
bind_json_schema(json_schema_uri: str, entity: Union[str, synapseclient.entity.Entity])

Bind a JSON schema to an entity

Parameters
  • json_schema_uri (str) – JSON schema URI

  • entity (str, Entity) – Synapse Entity or Synapse Id

bind_json_schema_to_entity(synapse_id: str, json_schema_uri: str)

Bind a JSON schema to an entity

Parameters
  • synapse_id (str) – Synapse Id

  • json_schema_uri (str) – JSON schema URI

create_json_schema(json_schema_body: dict, dry_run: bool = False)

Create a JSON schema

Parameters
  • json_schema_body (dict) – JSON schema body

  • dry_run (bool, optional) – Don’t store to Synapse. Default to False.

create_organization(organization_name: str)

Create a new organization

Parameters

organization_name (str) – JSON schema organization name

delete_json_schema(json_schema_uri: str)

Delete the given schema using its $id

Parameters

json_schema_uri (str) – JSON schema URI

delete_json_schema_from_entity(synapse_id: str)

Delete bound schema from entity

Parameters

synapse_id (str) – Synapse Id

delete_organization(organization_id: str)

Delete organization

Parameters

organization_id (str) – JSON schema organization Id

get_invalid_json_schema_validation(synapse_id: str)

Get a single page of invalid JSON schema validation results for a container Entity (Project or Folder).

Parameters

synapse_id (str) – Synapse Id

get_json_schema(entity: Union[str, synapseclient.entity.Entity])

Get a JSON schema associated to an Entity

Parameters

entity (str, Entity) – Synapse Entity or Synapse Id

get_json_schema_body(json_schema_uri: str)

Get registered JSON schema with its $id

Parameters

json_schema_uri (str) – JSON schema URI

get_json_schema_from_entity(synapse_id: str)

Get bound schema from entity

Parameters

synapse_id (str) – Synapse Id

get_json_schema_validation_statistics(synapse_id: str)

Get the summary statistic of json schema validation results for a container entity

Parameters

synapse_id (str) – Synapse Id

get_organization(organization_name: str)

Get a organization

Parameters

organization_name (str) – JSON schema organization name

get_organization_acl(organization_id: str)

Get ACL associated with Organization

Parameters

organization_id (str) – JSON schema organization Id

json_schema_validation(json_schema_uri: str)

Use a JSON schema for validation

Parameters

json_schema_uri (str) – JSON schema URI

list_json_schema_versions(organization_name: str, json_schema_name: str)

List version information for each JSON schema

Parameters
  • organization_name (str) – JSON schema organization name

  • json_schema_name (str) – JSON schema name

list_json_schemas(organization_name: str)

List JSON schemas for an organization

Parameters

organization_name (str) – JSON schema organization name

list_organizations()

List organizations

login(email: str = None, password: str = None, apiKey: str = None, sessionToken: str = None, rememberMe: bool = False, silent: bool = False, forced: bool = False, authToken: str = None)

Valid combinations of login() arguments:

  • email/username and password

  • email/username and apiKey (Base64 encoded string)

  • authToken

  • sessionToken (DEPRECATED)

If no login arguments are provided or only username is provided, login() will attempt to log in using

information from these sources (in order of preference):

  1. User’s personal access token from environment the variable: SYNAPSE_AUTH_TOKEN

  2. .synapseConfig file (in user home folder unless configured otherwise)

  3. cached credentials from previous login() where rememberMe=True was passed as a parameter

Parameters
  • email – Synapse user name (or an email address associated with a Synapse account)

  • password!!WILL BE DEPRECATED!! password. Please use authToken (Synapse personal access token)

  • apiKey!!WILL BE DEPRECATED!! Base64 encoded Synapse API key

  • sessionToken!!DEPRECATED FIELD!! User’s current session token. Using this field will ignore the following fields: email, password, apiKey

  • rememberMe – Whether the authentication information should be cached in your operating system’s credential storage.

  • authToken – A bearer authorization token, e.g. a personal access token, can be used in lieu of a password or apiKey

GNOME Keyring (recommended) or KWallet is recommended to be installed for credential storage on Linux systems. If it is not installed/setup, credentials will be stored as PLAIN-TEXT file with read and write permissions for the current user only (chmod 600). On Windows and Mac OS, a default credentials storage exists so it will be preferred over the plain-text file. To install GNOME Keyring on Ubuntu:

sudo apt-get install gnome-keyring

sudo apt-get install python-dbus  #(for Python 2 installed via apt-get)
OR
sudo apt-get install python3-dbus #(for Python 3 installed via apt-get)
OR
sudo apt-get install libdbus-glib-1-dev #(for custom installation of Python or vitualenv)
sudo pip install dbus-python #(may take a while to compile C code)

If you are on a headless Linux session (e.g. connecting via SSH), please run the following commands before running your Python session:

dbus-run-session -- bash #(replace 'bash' with 'sh' if bash is unavailable)
echo -n "REPLACE_WITH_YOUR_KEYRING_PASSWORD"|gnome-keyring-daemon -- unlock
Parameters
  • silent – Defaults to False. Suppresses the “Welcome …!” message.

  • forced – Defaults to False. Bypass the credential cache if set.

Example:

syn.login('my-username', 'secret-password', rememberMe=True)
#> Welcome, Me!

After logging in with the rememberMe flag set, an API key will be cached and used to authenticate for future logins:

syn.login()
#> Welcome, Me!
unbind_json_schema(entity: Union[str, synapseclient.entity.Entity])

Unbind a JSON schema from an entity

Parameters

entity (str, Entity) – Synapse Entity or Synapse Id

update_organization_acl(organization_id: str, resource_access: Sequence[Mapping[str, Sequence[str]]], etag: str)

Get ACL associated with Organization

Parameters
  • organization_id (str) – JSON schema organization Id

  • resource_access (list) – Resource access array

  • etag (str) – Etag

validate(entity: Union[str, synapseclient.entity.Entity])

Validate an entity based on the bound JSON schema

Parameters

entity (str, Entity) – Synapse Entity or Synapse Id

validate_children(entity: Union[str, synapseclient.entity.Entity])

Validate an entity and it’s children based on the bound JSON schema

Parameters

entity (str, Entity) – Synapse Entity or Synapse Id of a project or folder.

validate_entity_with_json_schema(synapse_id: str)

Get validation results of an entity against bound JSON schema

Parameters

synapse_id (str) – Synapse Id

validation_stats(entity: Union[str, synapseclient.entity.Entity])

Get validation statistics of an entity based on the bound JSON schema

Parameters

entity (str, Entity) – Synapse Entity or Synapse Id

class synapseclient.services.json_schema.JsonSchemaVersion(organization: synapseclient.services.json_schema.JsonSchemaOrganization, name: str, semantic_version: Optional[str] = None)

Json schema version response object

Parameters
  • organization (JsonSchemaOrganization) – JSON schema organization.

  • name (str) – Name of the JSON schema.

  • semantic_version (str, optional) – Version of JSON schema. Defaults to None.

bind_to_object(synapse_id: str)

Bind schema to an entity

Parameters

synapse_id (str) – Synapse Id to bind json schema to.

create(json_schema_body: dict, dry_run: bool = False)

Create JSON schema version

Parameters
  • json_schema_body (dict) – JSON schema body

  • dry_run (bool, optional) – Do not store to Synapse. Defaults to False.

Returns

JSON Schema

delete()

Delete the JSON schema version

expand()

Validate entities with schema

get()

Get the JSON Schema Version