Web Objects (Complex Models)

class hydra_server.server.complexmodels.Attr(parent=None)
  • id Integer(default=None)

  • name Unicode(default=None)

  • dimension_id Unicode(default=None)

  • description Unicode(default=None)

  • cr_date Unicode(default=None)

class Attributes
class hydra_server.server.complexmodels.AttrGroup(parent=None)
  • id Integer(default=None)

  • project_id Integer(default=None)

  • name Unicode(default=None)

  • layout AnyDict(min_occurs=0, max_occurs=1, default=None))

  • description Unicode(default=None)

  • exclusive Unicode(min_occurs=0, default=’N’)

  • cr_date Unicode(default=None)

class Attributes
class hydra_server.server.complexmodels.AttrGroupItem(parent=None)
  • group_id Integer(default=None)

  • attr_id Integer(default=None)

  • network_id Integer(default=None)

class Attributes
class hydra_server.server.complexmodels.AttributeData(*args, **kwargs)

A class which is returned by the server when a request is made for the data associated with an attribute.

  • resourceattrs SpyneArray(ResourceAttr)

  • resourcescenarios SpyneArray(ResourceScenario)

class Attributes
class hydra_server.server.complexmodels.Dataset(parent=None, include_metadata=True)
  • id Integer(min_occurs=0, default=None)

  • type Unicode

  • dimension Unicode(min_occurs=1, default=’dimensionless’)

  • unit Unicode(min_occurs=1, default=None)

  • name Unicode(min_occurs=1, default=None)

  • value Unicode(min_occurs=1, default=None)

  • hidden Unicode(min_occurs=0, default=’N pattern=”[YN]”)

  • created_by Integer(min_occurs=0, default=None)

  • cr_date Unicode(min_occurs=0, default=None)

  • metadata Unicode(min_occurs=0, default=’{}’)

class Attributes
class hydra_server.server.complexmodels.DatasetCollection(parent=None)
  • name Unicode(default=None)

  • id Integer(default=None)

  • dataset_ids SpyneArray(Integer)

  • cr_date Unicode(default=None)

class Attributes
class hydra_server.server.complexmodels.DatasetOwner(parent=None)
  • dataset_id Integer

  • user_id Integer

  • edit Unicode

  • view Unicode)

class Attributes
class hydra_server.server.complexmodels.Dimension(parent=None)

A dimension, with name and units

  • id Integer

  • name Unicode

  • units SpyneArray(Unicode)

  • description Unicode

  • project_id Integer

class Attributes
class hydra_server.server.complexmodels.HydraComplexModel(*args, **kwargs)

This is the superclass from which most hydra complex models inherit. It contains the namespace ‘server.complexmodels’, which all hydra complex models need.

class Attributes
  • id Integer(default=None)

  • name Unicode(default=None)

  • description Unicode(min_occurs=1, default=”“)

  • layout AnyDict(min_occurs=0, max_occurs=1, default=None)

  • node_1_id Integer(default=None)

  • node_2_id Integer(default=None))

  • status Unicode(default=’A** pattern=”[AX]”)

  • attributes SpyneArray(ResourceAttr)

  • types SpyneArray(TypeSummary)

  • cr_date Unicode(default=None)

class Attributes
class hydra_server.server.complexmodels.LoginResponse(*args, **kwargs)
class Attributes
class hydra_server.server.complexmodels.Network(parent=None, summary=False)
  • project_id Integer(default=None)

  • id Integer(default=None)

  • name Unicode(default=None)

  • description Unicode(min_occurs=1, default=None)

  • created_by Integer(default=None)

  • cr_date Unicode(default=None)

  • layout AnyDict(min_occurs=0, max_occurs=1, default=None)

  • status Unicode(default=’A’)

  • attributes SpyneArray(ResourceAttr)

  • scenarios SpyneArray(Scenario)

  • nodes SpyneArray(Node)

  • links SpyneArray(Link)

  • resourcegroups SpyneArray(ResourceGroup)

  • types SpyneArray(TypeSummary)

  • projection Unicode(default=None)

class Attributes
class hydra_server.server.complexmodels.NetworkExtents(parent=None)
  • network_id Integer(default=None)

  • min_x Decimal(default=0)

  • min_y Decimal(default=0)

  • max_x Decimal(default=0)

  • max_y Decimal(default=0)

class Attributes
class hydra_server.server.complexmodels.NetworkOwner(parent=None)
  • network_id Integer

  • user_id Integer

  • edit Unicode

  • view Unicode)

class Attributes
class hydra_server.server.complexmodels.Node(parent=None, summary=False)
  • id Integer(default=None)

  • name Unicode(default=None)

  • description Unicode(min_occurs=1, default=”“)

  • layout AnyDict(min_occurs=0, max_occurs=1, default=None)

  • x Double(min_occurs=1, default=0)

  • y Double(min_occurs=1, default=0)

  • status Unicode(default=’A** pattern=”[AX]”)

  • attributes SpyneArray(ResourceAttr)

  • types SpyneArray(TypeSummary)

  • cr_date Unicode(default=None)

class Attributes
class hydra_server.server.complexmodels.Note(parent=None)
  • id Integer

  • ref_key Unicode

  • ref_id Integer

  • value Unicode

  • created_by Integer

  • cr_date Unicode

class Attributes
class hydra_server.server.complexmodels.Perm(parent=None)
  • id Integer

  • name Unicode

  • code Unicode

class Attributes
class hydra_server.server.complexmodels.Plugin(parent=None)
  • name Unicode

  • location Unicode

  • params SpyneArray(PluginParam)

class Attributes
class hydra_server.server.complexmodels.PluginParam(parent=None)
  • name Unicode

  • value Unicode

class Attributes
class hydra_server.server.complexmodels.Project(parent=None)
  • id Integer(default=None)

  • name Unicode(default=None)

  • description Unicode(default=None)

  • status Unicode(default=’A’)

  • cr_date Unicode(default=None)

  • created_by Integer(default=None)

  • attributes SpyneArray(ResourceAttr)

  • attribute_data SpyneArray(ResourceScenario)

class Attributes
class hydra_server.server.complexmodels.ProjectOwner(parent=None)
  • project_id Integer

  • user_id Integer

  • edit Unicode

  • view Unicode)

class Attributes
class hydra_server.server.complexmodels.ProjectSummary(parent=None)
  • id Integer(default=None)

  • name Unicode(default=None)

  • description Unicode(default=None)

  • status Unicode(default=None)

  • cr_date Unicode(default=None)

  • created_by Integer(default=None)

class Attributes
class hydra_server.server.complexmodels.Resource(*args, **kwargs)
Superclass for anything which has a layout field:
  • nodes

  • links

  • network

  • scenario

  • project

class Attributes
class hydra_server.server.complexmodels.ResourceAttr(parent=None)
  • id Integer(min_occurs=0, default=None)

  • attr_id Integer(default=None)

  • ref_id Integer(min_occurs=0, default=None)

  • ref_key Unicode(min_occurs=0, default=None)

  • attr_is_var Unicode(min_occurs=0, default=’N’)

  • resourcescenario ResourceScenario

  • cr_date Unicode(default=None)

class Attributes
class hydra_server.server.complexmodels.ResourceAttrMap(parent=None)
  • resource_attr_id_a Integer(default=None)

  • resource_attr_id_b Integer(default=None)

  • attr_a_name Unicode(default=None)

  • attr_b_name Unicode(default=None)

  • ref_key_a Unicode(default=None)

  • ref_key_b Unicode(default=None)

  • ref_id_a Integer(default=None)

  • ref_id_b Integer(default=None)

  • resource_a_name Unicode(default=None)

  • resource_b_name Unicode(default=None)

  • network_a_id Integer(default=None)

  • network_b_id Integer(default=None)

class Attributes
class hydra_server.server.complexmodels.ResourceData(resourceattr=None, include_value='N')

An object which represents a resource attr, resource scenario and dataset all in one.

  • attr_id: The ID of the attribute to which this data belongs

  • scenario_id: The ID of the scenario in which this data has been assigned

  • resource_attr_id: The unique ID representing the attribute and resource combination

  • ref_key: Indentifies the type of resource to which this dataset is attached. Can be ‘NODE’, ‘LINK’, ‘GROUP’, ‘NETWORK’ or ‘PROJECT’

  • ref_id: The ID of the node, link, group, network, or project in question

  • attr_is_var: Flag to indicate whether this resource’s attribute is a variable and hence should be filled in by a model

  • dataset_id: The ID of the dataset which has been assigned to the resource attribute

  • dataset_type: The type of the dataset – can be scalar, descriptor, array or timeseries

  • dataset_dimension: The dimension of the dataset (This MUST match the dimension of the attribute)

  • dataset_unit: The unit of the dataset.

  • dataset_name: The name of the dataset. Most likely used for distinguishing similar datasets or searching for datasets

  • dataset_hidden: Indicates whether the dataset is hidden, in which case only authorised users can use the dataset.

  • dataset_metadata:: A dictionary of the metadata associated with the dataset. For example: {‘created_by’: “User 1”, “source”:”Import from CSV”}

  • dataset_value:

    Depending on what the dataset_type is, this can be a decimal value, a freeform string or a JSON string. For a timeseries for example, the datasset_value looks like:

    '{
        "H1" : {
    
                "2014/09/04 16:46:12:00":1,
    
                "2014/09/05 16:46:12:00":2,
    
                "2014/09/06 16:46:12:00":3,
    
                "2014/09/07 16:46:12:00":4},
    
    
        "H2" : {
    
                "2014/09/04 16:46:12:00":10,
    
                "2014/09/05 16:46:12:00":20,
    
                "2014/09/06 16:46:12:00":30,
    
                "2014/09/07 16:46:12:00":40},
    
    
        "H3" :  {
    
                "2014/09/04 16:46:12:00":100,
    
                "2014/09/05 16:46:12:00":200,
    
                "2014/09/06 16:46:12:00":300,
    
                "2014/09/07 16:46:12:00":400}
    
    }'
    
class Attributes
class hydra_server.server.complexmodels.ResourceGroup(parent=None, summary=False)
  • id Integer(default=None)

  • network_id Integer(default=None)

  • name Unicode(default=None)

  • description Unicode(min_occurs=1, default=”“)

  • status Unicode(default=’A** pattern=”[AX]”)

  • attributes SpyneArray(ResourceAttr)

  • types SpyneArray(TypeSummary)

  • cr_date Unicode(default=None)

class Attributes
class hydra_server.server.complexmodels.ResourceGroupDiff(parent=None)
  • scenario_1_items SpyneArray(ResourceGroupItem)

  • scenario_2_items SpyneArray(ResourceGroupItem))

class Attributes
class hydra_server.server.complexmodels.ResourceGroupItem(parent=None)
  • id Integer(default=None)

  • ref_id Integer(default=None)

  • ref_key Unicode(default=None)

  • group_id Integer(default=None)

  • cr_date Unicode(default=None)

class Attributes
class hydra_server.server.complexmodels.ResourceScenario(parent=None, attr_id=None)
  • resource_attr_id Integer(default=None)

  • attr_id Integer(default=None)

  • dataset_id Integer(default=None)

  • value Dataset

  • source Unicode

  • cr_date Unicode(default=None)

class Attributes
class hydra_server.server.complexmodels.ResourceScenarioDiff(parent=None)
  • resource_attr_id Integer(default=None)

  • scenario_1_dataset Dataset

  • scenario_2_dataset Dataset

class Attributes
class hydra_server.server.complexmodels.ResourceSummary(parent=None)
  • ref_key Unicode(default=None)

  • id Integer(default=None)

  • name Unicode(default=None)

  • description Unicode(min_occurs=1, default=”“)

  • attributes SpyneArray(ResourceAttr)),

  • types SpyneArray(TypeSummary)),

class Attributes
class hydra_server.server.complexmodels.ResourceTypeDef(*args, **kwargs)
  • ref_key Unicode(default=None)

  • ref_id Integer(default=None)

  • type_id Integer(default=None)

class Attributes
class hydra_server.server.complexmodels.Role(parent=None)
  • id Integer

  • name Unicode

  • code Unicode

  • roleperms SpyneArray(RolePerm)

  • roleusers SpyneArray(RoleUser)

class Attributes
class hydra_server.server.complexmodels.RolePerm(parent=None)
  • perm_id Integer

class Attributes
class hydra_server.server.complexmodels.RoleUser(parent=None)
  • user_id Integer

class Attributes
class hydra_server.server.complexmodels.Rule(parent=None)
  • id Integer

  • name Unicode

  • description Unicode

  • scenario_id Integer

  • ref_key Unicode

  • ref_id Integer

  • value Unicode

  • cr_date Unicode(default=None)

class Attributes
class hydra_server.server.complexmodels.Scenario(parent=None, summary=False)
  • id Integer(default=None)

  • name Unicode(default=None)

  • description Unicode(min_occurs=1, default=”“)

  • network_id Integer(default=None)

  • layout AnyDict(min_occurs=0, max_occurs=1, default=None)

  • status Unicode(default=’A** pattern=”[AX]”)

  • locked Unicode(default=’N** pattern=”[YN]”)

  • start_time Unicode(default=None)

  • end_time Unicode(default=None)

  • created_by Integer(default=None)

  • cr_date Unicode(default=None)

  • time_step Unicode(default=None)

  • resourcescenarios SpyneArray(ResourceScenario, default=None)

  • resourcegroupitems SpyneArray(ResourceGroupItem, default=None)

class Attributes
class hydra_server.server.complexmodels.ScenarioDiff(parent=None)
  • resourcescenarios SpyneArray(ResourceScenarioDiff)

  • groups ResourceGroupDiff

class Attributes
class hydra_server.server.complexmodels.Template(parent=None)
  • id Integer(default=None)

  • name Unicode(default=None)

  • layout AnyDict(min_occurs=0, max_occurs=1, default=None)

  • types SpyneArray(TemplateType)

  • cr_date Unicode(default=None)

class Attributes
class hydra_server.server.complexmodels.TemplateType(parent=None)
  • id Integer(default=None)

  • name Unicode(default=None)

  • resource_type Unicode(values=[‘GROUP’, ‘NODE’, ‘LINK’, ‘NETWORK’], default=None)

  • alias Unicode(default=None)

  • layout AnyDict(min_occurs=0, max_occurs=1, default=None)

  • template_id Integer(min_occurs=1, default=None)

  • typeattrs SpyneArray(TypeAttr)

  • cr_date Unicode(default=None)

class Attributes
class hydra_server.server.complexmodels.TypeAttr(parent=None)
  • attr_id Integer(min_occurs=1, max_occurs=1)

  • attr_name Unicode(default=None)

  • type_id Integer(default=None)

  • data_type Unicode(default=None)

  • dimension Unicode(default=None)

  • unit Unicode(default=None)

  • default_dataset_id Integer(default=None)

  • data_restriction AnyDict(default=None)

  • is_var Unicode(default=None)

  • description Unicode(default=None)

  • properties AnyDict(default=None)

  • cr_date Unicode(default=None)

class Attributes
class hydra_server.server.complexmodels.TypeSummary(parent=None)
  • name Unicode

  • id Integer

  • template_name Unicode

  • template_id Integer

class Attributes
class hydra_server.server.complexmodels.Unit(parent=None)
  • id Integer

  • name Unicode

  • abbr Unicode

  • abbreviation Unicode

  • cf Double

  • lf Double

  • info Unicode

  • description Unicode

  • dimension_id Integer

  • project_id Integer

class Attributes
class hydra_server.server.complexmodels.User(parent=None)
  • id Integer

  • username Unicode(default=None)

  • display_name Unicode(default=None)

  • password Unicode(default=None)

class Attributes
class hydra_server.server.complexmodels.ValidationError(error_text, scenario_id=None, ref_key=None, ref_id=None, ref_name=None, attr_name=None, attr_id=None, template_id=None, type_id=None, resource_attr_id=None, dataset_id=None)
  • scenario_id Integer(default=None)

  • ref_key Unicode(default=None)

  • ref_id Integer(default=None)

  • ref_name Unicode(default=None)

  • attr_name Unicode(default=None)

  • attr_id Integer(default=None)

  • template_id Integer(default=None)

  • type_id Integer(default=None)

  • resource_attr_id Integer(default=None)

  • dataset_id Integer(default=None)

  • error_text Unicode(default=None)

class Attributes

API functions

Projects

class hydra_server.server.project.ProjectService

The project SOAP service

static add_project(ctx, project)

Add a new project

Args:

project (complexmodels.Project): The new project to be added. The project does not include networks.

Returns:

complexmodels.Project: The project received, but with an ID this time.

Raises:

static delete_project(ctx, project_id)

Set the status of a project to ‘X’. This does NOT delete the project from the database (which also entails deleting all sub-networks, data etc). For that, use purge_project.

Args:

project_id (int): The ID of the project to delete.

Returns:

string: ‘OK’

Raises:

ResourceNotFoundError: If the Project is not found.

static get_network_project(ctx, network_id)

Get the project of a specified network

Args:

network_id (int): The ID of the network whose project details you want

Returns:

complexmodels.Project: The parent project of the specified Network

Raises:

ResourceNotFoundError: If the Network is not found.

static get_networks(ctx, project_id, include_data)

Get all networks in a project

Args:

project_id (int): The ID of the project whose networks you want. include_data (string) (‘Y’ or ‘N’): Include data with the networks? Defaults as ‘Y’ but using ‘N’ gives a significant performance boost.

Returns:

List(complexmodels.Network): All the project’s Networks.

Raises:

ResourceNotFoundError: If the Project is not found.

static get_project(ctx, project_id)

Get an existing Project

Args:

project_id (int): The ID of the project to retrieve

Returns:

complexmodels.Project: The requested project

Raises:

ResourceNotFoundError: If the project is not found.

static get_project_by_name(ctx, project_name)

If you don’t know the ID of the project in question, but do know the name, use this function to retrieve it.

Args:

project_name (string): The name of the project to retrieve

Returns:

complexmodels.Project: The requested project

Raises:

ResourceNotFoundError: If the project is not found.

static get_projects(ctx, user_id)

Get all the projects belonging to a user.

Args:

user_id (int): The user ID whose projects you want

Returns:

List(complexmodels.Project): The requested projects

Raises:

ResourceNotFoundError: If the User is not found.

static purge_project(ctx, project_id)

Delete a project from the DB completely. WARNING: THIS WILL DELETE ALL THE PROJECT’S NETWORKS AND CANNOT BE REVERSED!

Args:

project_id (int): The ID of the project to purge.

Returns:

string: ‘OK’

Raises:

ResourceNotFoundError: If the Project is not found.

static update_project(ctx, project)

Update a project

Args:

project (complexmodels.Project): The project to be updated. All the attributes of this project will be used to update the existing project

Returns:

complexmodels.Project: The updated project

Raises:

ResourceNotFoundError: If the project is not found.

Attributes

class hydra_server.server.attributes.AttributeGroupService
static add_attribute_group(ctx, attributegroup)

Add a new attribute group.

An attribute group is a container for attributes which need to be grouped in some logical way. For example, if the ‘attr_is_var’ flag isn’t expressive enough to delineate different groupings.

an attribute group looks like:
{

‘project_id’ : XXX, ‘name’ : ‘my group name’ ‘description : ‘my group description’ (optional) ‘layout’ : ‘my group layout’ (optional) ‘exclusive’ : ‘N’ (or ‘Y’ ) (optional, default to ‘N’)

}

static add_attribute_group_items(ctx, attributegroupitems)

Populate attribute groups with items. ** attributegroupitems : a list of items, of the form:

```{

‘attr_id’ : X, ‘group_id’ : Y, ‘network_id’ : Z,

}```

Note that this approach supports the possibility of populating groups within multiple networks at the same time.

When adding a group item, the function checks whether it can be added, based on the ‘exclusivity’ setup of the groups – if a group is specified as being ‘exclusive’, then any attributes within that group cannot appear in any other group (within a network).

static delete_attribute_group(ctx, group_id)

Delete an attribute group.

static delete_attribute_group_items(ctx, attributegroupitems)

remove attribute groups items . ** attributegroupitems : a list of items, of the form:

```{

‘attr_id’ : X, ‘group_id’ : Y, ‘network_id’ : Z,

}```

static get_attribute_group(ctx, group_id)
static get_attribute_item_groups(ctx, network_id, attr_id)

Get all the group items in a network with a given attribute_id

static get_group_attributegroup_items(ctx, network_id, group_id)

Get all the items in a specified group, within a network

static get_network_attributegroup_items(ctx, network_id)

Get all the group items in a network

static update_attribute_group(ctx, attributegroup)

Update an existing attribute group.

An attribute group is a container for attributes which need to be grouped in some logical way. For example, if the ‘attr_is_var’ flag isn’t expressive enough to delineate different groupings.

an attribute group looks like:
{

‘project_id’ : XXX, ‘name’ : ‘my group name’ ‘description : ‘my group description’ (optional) ‘layout’ : ‘my group layout’ (optional) ‘exclusive’ : ‘N’ (or ‘Y’ ) (optional, default to ‘N’)

}

class hydra_server.server.attributes.AttributeService

The attribute SOAP service

static add_attribute(ctx, attr)

Add a generic attribute, which can then be used in creating a resource attribute, and put into a type.

(Attr){
    name = "Test Attr"
    dimen = "very big"
    description = "I am a very big attribute"
}
Args:

attr (complexmodels.Attr): An attribute object, as described above.

Returns:

complexmodels.Attr: An attribute object, similar to the one sent in but with an ID.

static add_attributes(ctx, attrs)

Add multiple generic attributes

Args:
attrs (List[Attr]): A list of attribute complex models,

as described above.

Returns:
List[Attr]: A list of attribute complex models,

reflecting the ones sent in.

static add_group_attribute(ctx, group_id, attr_id, is_var)

Add a resource attribute to a group.

Args:

group_id (int): The ID of the Group attr_id (int): THe ID if the attribute being added. is_var (char): Y or N. Indicates whether the attribute is a variable or not.

Returns:

complexmodels.ResourceAttr: The newly created group attribute

Raises:

ResourceNotFoundError: If the group or attribute do not exist HydraError: If this addition causes a duplicate attribute on the group.

static add_group_attrs_from_type(ctx, type_id, group_id)

Adds all the attributes defined by a type to a group.

Args:

type_id (int): ID of the type used to get the resource attributes from group_id (int): ID of the group

Returns:

List(complexmodels.ResourceAttr): All the newly created group attributes

Raises:

ResourceNotFoundError if the type_id or group_id are not in the DB

Add a resource attribute to a link.

Args:

link_id (int): The ID of the Link attr_id (int): THe ID if the attribute being added. is_var (char): Y or N. Indicates whether the attribute is a variable or not.

Returns:

complexmodels.ResourceAttr: The newly created link attribute

Raises:

ResourceNotFoundError: If the link or attribute do not exist HydraError: If this addition causes a duplicate attribute on the link.

Adds all the attributes defined by a type to a link.

Args:

type_id (int): ID of the type used to get the resource attributes from link_id (int): ID of the link

Returns:

List(complexmodels.ResourceAttr): All the newly created link attributes

Raises:

ResourceNotFoundError if the type_id or link_id are not in the DB

static add_network_attribute(ctx, network_id, attr_id, is_var)

Add a resource attribute to a network.

Args:

network_id (int): ID of the network attr_id (int): ID of the attribute to assign to the network is_var (string) ‘Y’ or ‘N’. Indicates whether this attribute is

a variable or not. (a variable is typically the result of a model run, so therefore doesn’t need data assigned to it initially)

Returns:

complexmodels.ResourceAttr: A complex model of the newly created resource attribute.

Raises:

ResourceNotFoundError: If the network or attribute are not in the DB. HydraError : If the attribute is already on the network.

static add_network_attrs_from_type(ctx, type_id, network_id)

Adds all the attributes defined by a type to a network.

Args:

type_id (int): ID of the type used to get the resource attributes from network_id (int): ID of the network

Returns:

List(complexmodels.ResourceAttr): All the newly created network attributes

Raises:

ResourceNotFoundError if the type_id or network_id are not in the DB

static add_node_attribute(ctx, node_id, attr_id, is_var)

Add a resource attribute to a node.

Args:

node_id (int): The ID of the Node attr_id (int): THe ID if the attribute being added. is_var (char): Y or N. Indicates whether the attribute is a variable or not.

Returns:

complexmodels.ResourceAttr: The newly created node attribute

Raises:

ResourceNotFoundError: If the node or attribute do not exist HydraError: If this addition causes a duplicate attribute on the node.

static add_node_attrs_from_type(ctx, type_id, node_id)

Adds all the attributes defined by a type to a node.

Args:

type_id (int): ID of the type used to get the resource attributes from node_id (int): ID of the node

Returns:

List(complexmodels.ResourceAttr): All the newly created node attributes

Raises:

ResourceNotFoundError if the type_id or node_id are not in the DB

static check_attr_dimension(ctx, attr_id)

Check that the dimension of the resource attribute data is consistent with the definition of the attribute. If the attribute says ‘volume’, make sure every dataset connected with this attribute via a resource attribute also has a dimension of ‘volume’.

Args:

attr_id (int): The ID of the attribute you want to check

Returns:

string: ‘OK’ if all is well.

Raises:

HydraError: If a dimension mismatch is found.

static check_mapping_exists(ctx, resource_attr_id_source, resource_attr_id_target)

Check whether a mapping exists between two resource attributes This does not check whether a reverse mapping exists, so order is important here.

Args:

resource_attr_id_source (int): The source resource attribute resource_attr_id_target (int) (optional): The target resource attribute

Returns:

string: ‘Y’ if a mapping between the source and target exists. ‘N’ in every other case.

static delete_attribute_mapping(ctx, resource_attr_a, resource_attr_b)

Delete a mapping which said one resource attribute from one network was the same as the resource attribute in another.

Args:

resource_attr_a (int): The ID of the source resoure attribute resource_attr_b (int): The ID of the target resoure attribute

Returns:

string: ‘OK’ if all is well. If the mapping isn’t there, it’ll still return ‘OK’, so make sure the IDs are correct!

static delete_mappings_in_network(ctx, network_id, network_2_id)

Delete all the resource attribute mappings in a network. If another network is specified, only delete the mappings between the two networks.

Args:

network_id (int): The network you want to delete the mappings from (both from and to) network_2_id (int) (optional): The partner network

Returns:

string: ‘OK’

static delete_resource_attribute(ctx, resource_attr_id)

Add a resource attribute attribute to a resource (Duplicate of delete_resourceattr)

Args:

resource_attr_id (int): ID of the complex model to be deleted

Returns:

unicode: ‘OK’

Raises:

ResourceNotFoundError if the resource_attr_id is not in the DB

static delete_resourceattr(ctx, resource_attr_id)

Deletes a resource attribute and all associated data. *WILL BE DEPRECATED*

Args:

resource_attr_id (int): ID of the complex model to be deleted

Returns:

unicode: ‘OK’

Raises:

ResourceNotFoundError if the resource_attr_id is not in the DB

static get_all_attributes(ctx)

Get all the attributes in the system

Args:

None

Returns:

List[Attr]: A list of attribute complex models

static get_all_group_attributes(ctx, network_id, template_id)

Get all the resource attributes for all the groups in the network.

Args:

network_id (int): The ID of the network that you want the group attributes from template_id (int) (optional): If this is specified, then it will only return the attributes in this template.

Returns:

List(complexmodels.ResourceAttr): The resource attributes of all the groups in the network.

Get all the resource attributes for all the links in the network.

Args:

network_id (int): The ID of the network that you want the link attributes from template_id (int) (optional): If this is specified, then it will only return the attributes in this template.

Returns:

List(complexmodels.ResourceAttr): The resource attributes of all the links in the network.

static get_all_node_attributes(ctx, network_id, template_id)

Get all the resource attributes for all the nodes in the network.

Args:

network_id (int): The ID of the network that you want the node attributes from template_id (int) (optional): If this is specified, then it will only return the attributes in this template.

Returns:

List(complexmodels.ResourceAttr): The resource attributes of all the nodes in the network.

static get_attribute(ctx, name, dimension)

Get a specific attribute by its name and dimension (this combination is unique for attributes in Hydra Platform).

Args:

name (unicode): The name of the attribute dimension (unicode): The dimension of the attribute

Returns:
complexmodels.Attr: An attribute complex model.

Returns None if no attribute is found.

static get_attribute_by_id(ctx, ID)

Get a specific attribute by its ID.

Args:

ID (int): The ID of the attribute

Returns:
complexmodels.Attr: An attribute complex model.

Returns None if no attribute is found.

static get_attributes(ctx, attrs)
Get a list of attribute, by their names and dimension. Takes a list

of attribute objects, picks out their name & dimension, finds the appropriate attribute in the DB and updates the incoming attribute with an ID. The same attributes go out that came in, except this time with an ID. If one of the incoming attributes does not match, this attribute is not returned.

Args:

attrs (List(Attr)): A list of attribute complex models

Returns:

List(complexmodels.Attr): List of Attr complex models

static get_group_attributes(ctx, group_id, type_id)

Get all a group’s attributes.

Args:

group_id (int): ID of the group type_id (int) (optional): ID of the type. If specified will only return the resource attributes relative to that type

Returns:

List(complexmodels.ResourceAttr): All the group’s attributes

Raises:

ResourceNotFoundError if the type_id or group_id do not exist.

Get all a link’s attributes.

Args:

link_id (int): ID of the link type_id (int) (optional): ID of the type. If specified will only return the resource attributes relative to that type

Returns:

List(complexmodels.ResourceAttr): All the link’s attributes

Raises:

ResourceNotFoundError if the type_id or link_id do not exist.

static get_mappings_in_network(ctx, network_id, network_2_id)

Get all the resource attribute mappings in a network (both from and to). If another network is specified, only return the mappings between the two networks.

Args:

network_id (int): The network you want to check the mappings of (both from and to) network_2_id (int) (optional): The partner network

Returns:

List(complexmodels.ResourceAttrMap): All the mappings to and from the network(s) in question.

static get_network_attributes(ctx, network_id, type_id)

Get all a network’s attributes (not the attributes of the nodes and links. just the network itself).

Args:

network_id (int): ID of the network type_id (int) (optional): ID of the type. If specified will only return the resource attributes relative to that type

Returns:

List(complexmodels.ResourceAttr): All the network attributes

Raises:

ResourceNotFoundError if the type_id or network_id are not in the DB

static get_node_attributes(ctx, node_id, type_id)

Get all a node’s attributes.

Args:

node_id (int): ID of the node type_id (int) (optional): ID of the type. If specified will only return the resource attributes relative to that type

Returns:

List(complexmodels.ResourceAttr): All the node’s attributes

Raises:

ResourceNotFoundError if the type_id or node_id do not exist.

static get_node_mappings(ctx, node_id, node_2_id)

Get the mappings for all the attributes of a given node. If a second node is specified, return only the mappings between these nodes..

Args:

node_id (int): The node you want to delete the mappings from (both from and to) node_2_id (int) (optional): The partner node

Returns:

List(complexmodels.ResourceAttrMap): All the mappings to and from the node(s) in question.

static get_template_attributes(ctx, template_id)

Get all the attributes in a template. Args

param (int) template_id

Returns

List(Attr)

static set_attribute_mapping(ctx, resource_attr_a, resource_attr_b)

Define one resource attribute from one network as being the same as that from another network.

Args:

resource_attr_a (int): The ID of the source resoure attribute resource_attr_b (int): The ID of the target resoure attribute

Returns:

string: ‘OK’ if all is well.

Raises:

ResourceNotFoundError: If either resource attribute is not found.

static update_attribute(ctx, attr)

Update a generic attribute, which can then be used in creating a resource attribute, and put into a type.

(Attr){
    id = 1020
    name = "Test Attr"
    dimen = "very big"
    description = "I am a very big attribute"
}
Args:

attr (complexmodels.Attr): An attribute complex model, as described above.

Returns:

complexmodels.Attr: An attribute complex model, reflecting the one sent in.

static update_resource_attribute(ctx, resource_attr_id, is_var)

Update a resource attribute (which means update the is_var flag as this is the only thing you can update on a resource attr)

Args:

resource_attr_id (int): ID of the complex model to be updated is_var (unicode): ‘Y’ or ‘N’

Returns:

List(complexmodels.ResourceAttr): Updated ResourceAttr

Raises:

ResourceNotFoundError if the resource_attr_id is not in the DB

Scenarios

class hydra_server.server.scenario.ScenarioService

The scenario SOAP service as all resources already exist, there is no need to worry about negative IDS

static activate_scenario(ctx, scenario_id)

Set the status of a scenario to ‘X’.

static add_data_to_attribute(ctx, scenario_id, resource_attr_id, dataset)

Add data to a resource scenario outside of a network update

static add_scenario(ctx, network_id, scen, return_summary)

Add a scenario to a specified network.

static bulk_update_resourcedata(ctx, scenario_ids, resource_scenarios)

Update the data associated with a scenario. Data missing from the resource scenario will not be removed from the scenario. Use the remove_resourcedata for this task.

static copy_data_from_scenario(ctx, resource_attr_ids, source_scenario_id, target_scenario_id)

Copy the datasets from a source scenario into the equivalent resource scenarios in the target scenario. Parameters are a list of resource attribute IDS, the ID of the source scenario and the ID of the target scenario.

static create_child_scenario(ctx, scenario_id, child_name)

Create a new scenario which inherits from the specified scenario

static delete_resourcedata(ctx, scenario_id, resource_scenario)

Remove the data associated with a resource in a scenario.

static delete_scenario(ctx, scenario_id)

Set the status of a scenario to ‘X’.

static get_attribute_datasets(ctx, attr_id, scenario_id, get_parent_data)

Get all the datasets from resource attributes with the given attribute ID in the given scenario.

Return a list of resource attributes with their associated resource scenarios (and values).

static get_dataset_scenarios(ctx, dataset_id)

Get all the scenarios attached to a dataset @returns a list of scenario_ids

Get all the resource scenarios for a given link in a given scenario. If type_id is specified, only return the resource scenarios for the attributes within the type.

static get_network_data(ctx, network_id, scenario_id, type_id, get_parent_data)

Get all the resource scenarios for a given network in a given scenario. If type_id is specified, only return the resource scenarios for the attributes within the type.

static get_node_attribute_data(ctx, node_ids, attr_ids)

Get the data for multiple attributes on multiple nodes across multiple scenarios. @returns a list of AttributeData objects, which consist of a list of ResourceAttribute objects and a list of corresponding ResourceScenario objects.

static get_node_data(ctx, node_id, scenario_id, type_id, get_parent_data)

Get all the resource scenarios for a given node in a given scenario. If type_id is specified, only return the resource scenarios for the attributes within the type.

static get_resource_scenario(ctx, resource_attr_id, scenario_id, get_parent_data)

Get the resource scenario object for a given resource atttribute and scenario. This is done when you know the attribute, resource and scenario and want to get the value associated with it.

The get_parent_data flag indicates whether we should look only at this scenario, or if the resource scenario does not exist on this scenario to look in its parent.

static get_resourcegroup_data(ctx, resourcegroup_id, scenario_id, type_id, get_parent_data)

Get all the resource scenarios for a given resourcegroup in a given scenario. If type_id is specified, only return the resource scenarios for the attributes within the type.

static get_scenario(ctx, scenario_id, return_summary, get_parent_data)

Get the specified scenario

static purge_scenario(ctx, scenario_id)

Set the status of a scenario to ‘X’.

static set_resourcescenario_dataset(ctx, resource_attr_id, scenario_id, dataset_id)

A short-hand way of creating a resource scenario. This function says: assign this datset ID to this resource attribute in this scenario. All the IDs must already exist.

static update_resourcedata(ctx, scenario_id, resource_scenarios)

Update the data associated with a scenario. Data missing from the resource scenario will not be removed from the scenario. Use the remove_resourcedata for this task.

static update_scenario(ctx, scen, update_data, update_groups, return_summary)

Update a single scenario as all resources already exist, there is no need to worry about negative IDS

User Management

class hydra_server.server.users.UserService

The user soap service

static add_perm(ctx, perm)

Add a new permission. A permission defines a particular action that a user can perform. A permission is independent of roles and are added to roles later.

Args:

perm (complexmodels.Perm): The new permission.

Returns:

complexmodels.Perm: The new permission

static add_role(ctx, role)

Add a new role. A role is the highest level in the permission tree and is container for permissions. Users are then assigned a role, which gives them the specified permissions

Args:

role (complexmodels.Role): The role to be added

Returns:

complexmodels.Role: The newly created role, complete with ID

static add_user(ctx, user)

Add a new user.

Args:

user (complexmodels.User): The user to be added, including username, display name and password

Returns:

complexmodels.User: The newly added user, without password

Raises:

ResourceNotFoundError: If the uid is not found

static delete_perm(ctx, perm_id)

Permenantly delete a permission

Args:

perm_id (int): The permission to be deleted

Returns:

string: ‘OK’

Raises:

ResourceNotFoundError: If the perm_id is not found

static delete_role(ctx, role_id)

Permenantly delete a role (and all its sub-permissions and users)

Args:

role_id (int): The role to be deleted

Returns:

string: ‘OK’

Raises:

ResourceNotFoundError: If the role_id is not found

static delete_role_perm(ctx, role_id, perm_id)

Remove a permission from a role

Args:

role_id (int): The role to lose the permission perm_id (int): The permission being removed from the role

Returns:

string: ‘OK’

Raises:

ResourceNotFoundError: If the role does not contain the permission or if the userermission or role do not exist.

static delete_user(ctx, user_id)

Delete a user permenantly from the DB.

Args:

user_id (int): The ID user to be deleted.

Returns:

string: ‘OK’

Raises:

ResourceNotFoundError: If the user_id is not found

static delete_user_role(ctx, user_id, role_id)

Remove a user from a role

Args:

user_id (int): The user to be removed from the role role_id (int): The role to lose the user

Returns:

string: ‘OK’

Raises:

ResourceNotFoundError: If the role does not contain the user or if the user or role do not exist.

static get_all_perms(ctx)

Get all permissions

Args:

Returns:

List(complexmodels.Perm): All the permissions in the system

Raises:

static get_all_roles(ctx)

Get all roles

Args:

Returns:

List(complexmodels.Role): All the roles in the system

Raises:

static get_all_users(ctx)

Get the username & ID of all users.

Args:

Returns:

List(complexmodels.User): All the users in the system

Raises:

static get_perm(ctx, perm_id)

Get a permission, by ID

Args:

perm_id (int): The ID of the permission

Returns:

complexmodels.Perm: The permission

Raises:

ResourceNotFoundError: If the permission does not exist

static get_perm_by_code(ctx, perm_code)

Get a permission by its code. Permission IDS change between hydra instances. Codes are more stable.

Args:

perm_id (int): The code of the permission.

Returns:

complexmodels.Perm: The permission

Raises:

ResourceNotFoundError: If the permission does not exist

static get_role(ctx, role_id)

Get a role by its ID.

Args:

role_id (int): The ID of the role to retrieve

Returns:

complexmodels.Role: The role

Raises:

ResourceNotFoundError: If the role does not exist

static get_role_by_code(ctx, role_code)

Get a role by its code instead of ID (IDS can change between databases. codes are more stable)

Args:

role_code (string): The code of the role to retrieve

Returns:

complexmodels.Role: The role

Raises:

ResourceNotFoundError: If the role does not exist

static get_user_by_name(ctx, username)

Get a user by username

Args:

username (string): The username being searched for

Returns:

complexmodels.User: The requested user, or None

static get_user_permissions(ctx, user_id)

Get all the permissions granted to the user, based on all the roles that the user is in. Args:

user_id (int): The user whose permissions you want

Returns:

List(complexmodels.Perm): The user’s permissions

Raises:

ResourceNotFoundError: If the user does not exist

static get_user_roles(ctx, user_id)

Get the roles assigned to a user. (A user can have multiple roles)

Args:

user_id (int): The ID of the user whose roles you want

Returns:

List(complexmodels.Role): The roles of the user

Raises:

ResourceNotFoundError: If the user does not exist

static get_username(ctx, uid)

Get a user’s username.

Args:

uid (int): The ID of the user

Returns:

string: the user’s username

Raises:

ResourceNotFoundError: If the uid is not found

static set_role_perm(ctx, role_id, perm_id)

Assign a permission to a role

Args:

role_id (int): The role to receive the permission perm_id (int): The permission being added to the role

Returns:

complexmodels.Role: The newly updated role, complete with new permission

Raises:

ResourceNotFoundError: If the role or permission do not exist

static set_user_role(ctx, user_id, role_id)

Assign a user to a role

Args:

user_id (int): The user to be given the new role role_id (int): The role to receive the new user

Returns:

complexmodels.Role: Returns the role to which the user has been added. (contains all the user roles).

Raises:

ResourceNotFoundError: If the user_id or role_id do not exist

static update_role(ctx, role)

Update a role. Used to add multiple permissions and users to a role in one go.

Args:

role (complexmodels.Role): The role with new users & permissions

Returns:

complexmodels.Role: The newly updated role

Raises:

ResourceNotFoundError: If the role or any users or permissions do not exist

static update_user_display_name(ctx, user)

Update a user’s display name

Args:

user (complexmodels.User): The user to be updated. Only the display name is updated

Returns:

complexmodels.User: The updated user, without password

Raises:

ResourceNotFoundError: If the uid is not found

static update_user_password(ctx, user_id, new_password)

Update a user’s password

Args:

user_id (int): The ID user to be updated. new_password (string): The new password.

Returns:

complexmodels.User: The updated user, without password

Raises:

ResourceNotFoundError: If the user_id is not found

static whoami(ctx)

Get the user object of the requesting user.

Args:

Returns:

User: the user object

Raises:

ResourceNotFoundError: If the uid is not found

Plugins

class hydra_server.server.plugins.PluginService

Plugin SOAP service

static check_plugin_status(ctx, plugin_name, pid)

Check the status of a plugin by looking into the log file for the PID

Args:

plugin_name (string): The name of the plugin being checked (used to identify the log file to look in) pid (int): The ID of the plugin to check

Returns:

string: The logs produced by the plugin. If the PID is not correct, return “No log found for PID %s in %s”

Raises:

IOError: If the log file does not exist for the plugin name

static get_plugins(ctx)

Get all available plugins

Args:

Returns:

List(string): A list of all the available plugins (the contents of plugin.xml)

static run_plugin(ctx, plugin)

Run a plugin

Args:

plugin (Plugin): A plugin object containing the location of the plugin and its parameters.

Returns:

string: The process ID of the plugin

Resource Templates

class hydra_server.server.template.TemplateService

The template SOAP service

static add_template(ctx, tmpl)

Add template and a type and typeattrs.

static add_templatetype(ctx, templatetype)

Add a template type with typeattrs.

static add_typeattr(ctx, typeattr)

Add an typeattr to an existing type.

static apply_template_to_network(ctx, template_id, network_id)

Given a template and a network, try to match up and assign all the nodes & links in the network to the types in the template

static assign_type_to_resource(ctx, type_id, resource_type, resource_id)

Assign new type to a resource. This function checks if the necessary attributes are present and adds them if needed. Non existing attributes are also added when the type is already assigned. This means that this function can also be used to update resources, when a resource type has changed.

static assign_types_to_resources(ctx, resource_types)

Assign new types to list of resources. This function checks if the necessary attributes are present and adds them if needed. Non existing attributes are also added when the type is already assigned. This means that this function can also be used to update resources, when a resource type has changed.

static delete_template(ctx, template_id)

Update template and a type and typeattrs.

static delete_templatetype(ctx, type_id)

Update template and a type and typeattrs.

static delete_typeattr(ctx, typeattr)

Remove an typeattr from an existing type

static get_matching_resource_types(ctx, resource_type, resource_id)

Get the possible types of a resource by checking its attributes against all available types.

@returns A list of TypeSummary objects.

static get_network_as_xml_template(ctx, network_id)

Turn an existing network into an xml template using its attributes. If an optional scenario ID is passed in, default values will be populated from that scenario.

static get_template(ctx, template_id)

Get a specific resource template template, either by ID or name.

static get_template_by_name(ctx, template_name)

Get a specific resource template, either by ID or name.

static get_templates(ctx)

Get all resource template templates.

static get_templatetype(ctx, type_id)

Get a specific resource type by ID.

static get_templatetype_by_name(ctx, template_id, type_name)

Get a specific resource type by name.

static remove_attr_from_type(ctx, type_id, attr_id)

Remove an attribute from a type

static remove_template_from_network(ctx, network_id, template_id, remove_attrs)

Given a template and a network, try to match up and assign all the nodes & links in the network to the types in the template

static remove_type_from_resource(ctx, type_id, resource_type, resource_id)

Remove a resource type trom a resource

static update_template(ctx, tmpl)

Update template and a type and typeattrs.

static update_templatetype(ctx, templatetype)

Update a resource type and its typeattrs. New typeattrs will be added. typeattrs not sent will be ignored. To delete typeattrs, call delete_typeattr

static upload_template_xml(ctx, template_xml)

Add the template, type and typeattrs described in an XML file.

Delete type, typeattr entries in the DB that are not in the XML file The assumption is that they have been deleted and are no longer required.

static validate_attr(ctx, resource_attr_id, scenario_id, template_id)

Validate that the value of a specified resource attribute is valid relative to the data restrictions specified on the template. If no template is specified, (set as null), then validation will be made against every template on the network.

Units and Dimensions

class hydra_server.server.units.UnitService

DIMENSION FUNCTIONS - GET

static add_dimension(ctx, dimension)

Add a physical dimensions (such as Volume or Speed) to the servers list of dimensions. If the dimension already exists, nothing is done.

static add_unit(ctx, unit)

Add a physical unit to the servers list of units. The Hydra server provides a complex model Unit which should be used to add a unit.

A minimal example:

from HydraLib import PluginLib

cli = PluginLib.connect()

new_unit = cli.factory.create('hyd:Unit')
new_unit.name = 'Teaspoons per second'
new_unit.abbr = 'tsp s^-1'
new_unit.cf = 0               # Constant conversion factor
new_unit.lf = 1.47867648e-05  # Linear conversion factor
new_unit.dimension = 'Volumetric flow rate'
new_unit.info = 'A flow of one teaspoon per second.'

cli.service.add_unit(new_unit)
static check_consistency(ctx, unit, dimension)

Check if a given units corresponds to a physical dimension.

static convert_dataset(ctx, dataset_id, to_unit)

Convert a whole dataset (specified by ‘dataset_id’ to new unit (‘to_unit’).

static convert_unit(ctx, value, unit1, unit2)

Convert a SINGLE value from one unit to another one.

Example:

>>> cli = PluginLib.connect()
>>> cli.service.convert_units(20.0, 'm', 'km')
0.02
static convert_units(ctx, values, unit1, unit2)

Convert a list of values from one unit to another one.

Example:

>>> cli = PluginLib.connect()
>>> cli.service.convert_units(20.0, 'm', 'km')
0.02
static delete_dimension(ctx, dimension_id)

Delete a physical dimension from the list of dimensions. Please note that deleting works only for dimensions listed in the custom file.

static delete_unit(ctx, unit_id)

Delete a unit from the custom unit collection.

static get_dimension(ctx, dimension_id)

Gets the dimension details and the list of all units assigned to the dimension.

static get_dimensions(ctx)

Gets a list of all physical dimensions available on the server.

static get_unit(ctx, unit_id)

Gets the Unit details

static get_unit_dimension(ctx, unit1)

Get the corresponding physical dimension for a given unit.

Example:

>>> cli = PluginLib.connect()
>>> cli.service.get_dimension('m')
Length
static get_units(ctx)

Get a list of all units corresponding to a physical dimension.

static is_global_dimension(ctx, dimension_id)

Returns True if the dimension is global, False otherwise

static is_global_unit(ctx, unit_id)

Returns True if the dimension is global, False otherwise

static update_dimension(ctx, dimension)

update a physical dimensions (such as Volume or Speed) to the servers list of dimensions.

static update_unit(ctx, unit)

Update an existing unit added to the custom unit collection. Please not that units built in to the library can not be updated.

Static Files

class hydra_server.server.static.FileService

The network SOAP service.

class hydra_server.server.static.ImageService

The network SOAP service.