Skip to content

Schemas and Autogenerated Classes

Plugin operations will sometimes need to work with data in these custom formats. For example, the configure operation will accept snapshot data as an input, and must produce source config data as an output.

To enable this, Python classes are generated from the snapshot schema. The aforementioned inputs and outputs are instances of these autogenerated classes.

Info

Autogenerated Python code will use lower_case_with_underscores as attribute names as per Python variable naming conventions. That is, if we were to use mountLocation as the schema property name, it would be called mount_location in the generated Python code.

RepositoryDefinition

Defines properties used to identify a Repository.

RepositoryDefinition Schema

The plugin must also decide on a name field and a set of identityFields to display and uniquely identify the repository.

{
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "name": { "type": "string" },
    "path": { "type": "string" }
  },
  "identityFields": ["name", "path"],
  "nameField": "name"
}

RepositoryDefinition Class

Autogenerated based on the RepositoryDefinition Schema.

class RepositoryDefinition:

  def __init__(self, repository_name, repository_path):
    self._inner_dict = {"name": repository_name, "path": repository_path}

To use the class:

from generated.defintions import RepositoryDefinition

repository = RepositoryDefinition()
repository.name = "name"
repository.path = "/some/path"

SourceConfigDefinition

Defines properties used to identify a Source Config.

SourceConfigDefinition Schema

The plugin must also decide on a name field and a set of identityFields to display and uniquely identify the source config.

{
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "name": { "type": "string" },
    "path": { "type": "string" }
  },
  "identityFields": ["name"],
  "nameField": "name"
}

SourceConfigDefinition Class

Autogenerated based on the SourceConfigDefinition Schema.

class SourceConfigDefinition:

  def __init__(self, config_name, config_path):
    self._inner_dict = {"name": config_name, "path": config_path}

To use the class:

from generated.defintions import SourceConfigDefinition

source_config = SourceConfigDefinition()
source_config.name = "name"
source_config.path = "/some/path"

LinkedSourceDefinition

Defines properties used to identify linked sources.

LinkedSourceDefinition Schema

{
  "type": "object",
  "required": ["name", "port"],
  "additionalProperties": false,
  "properties": {
    "name": { "type": "string" },
    "port": { "type": "integer" }
}

LinkedSourceDefinition Class

Autogenerated based on the LinkedSourceDefinition Schema.

class LinkedSourceDefinition:

  def __init__(self, source_name, source_port):
    self._inner_dict = {"name": source_name, "port": source_port}

To use the class:

from generated.defintions import LinkedSourceDefinition

source = LinkedSourceDefinition("name", 1000)
name = source.name
port = source.port

VirtualSourceDefinition

Defines properties used to identify virtual sources.

VirtualSourceDefinition Schema

{
  "type": "object",
  "required": ["name", "port"],
  "additionalProperties": false,
  "properties": {
    "name": { "type": "string" },
    "port": { "type": "integer" }
}

VirtualSourceDefinition Class

Autogenerated based on the VirtualSourceDefinition Schema.

class VirtualSourceDefinition:

  def __init__(self, source_name, source_port):
    self._inner_dict = {"name": source_name, "port": source_port}

To use the class:

from generated.defintions import VirtualSourceDefinition

source = VirtualSourceDefinition("name", 1000)
name = source.name
port = source.port

SnapshotDefinition

Defines properties used to snapshots.

SnapshotDefinition Schema

{
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "version": { "type": "string" },
    "version": { "type": "integer" }
}

SnapshotDefinition Class

Autogenerated based on the VirtualSourceDefinition Schema.

class VirtualSourceDefinition:

  def __init__(self, snapshot_version, snapshot_transaction_id):
    self._inner_dict = 
      {
        "version": snapshot_version, 
        "transaction_id": snapshot_transaction_id
      }

To use the class:

from generated.defintions import SnapshotDefinition

snapshot = SnapshotDefinition()
snapshot.version = "1.2.3"
snapshot.transaction_id = 1000