Web Objects (Complex Models)

class HydraServer.soap_server.hydra_complexmodels.Attr(parent=None)
  • id Integer(default=None)
  • name Unicode(default=None)
  • dimen Unicode(default=None)
  • description Unicode(default=None)
  • cr_date Unicode(default=None)
class HydraServer.soap_server.hydra_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 HydraServer.soap_server.hydra_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=’{}’)
get_metadata_as_dict(user_id=None, source=None)

Convert a metadata json string into a dictionary.

Parameters:
  • user_id (int) – Optional: Insert user_id into the metadata if specified
  • source (string) – Optional: Insert source (the name of the app typically) into the metadata if necessary.
Returns:

THe metadata as a python dictionary

Return type:

dict

parse_value()

Turn the value of an incoming dataset into a hydra-friendly value.

class HydraServer.soap_server.hydra_complexmodels.DatasetCollection(parent=None)
  • name Unicode(default=None)
  • id Integer(default=None)
  • dataset_ids SpyneArray(Integer)
  • cr_date Unicode(default=None)
class HydraServer.soap_server.hydra_complexmodels.DatasetOwner(parent=None)
  • dataset_id Integer
  • user_id Integer
  • edit Unicode
  • view Unicode)
class HydraServer.soap_server.hydra_complexmodels.Dimension(name, units)
A dimension, with name and units
  • name Unicode
  • units SpyneArray(Unicode)
class HydraServer.soap_server.hydra_complexmodels.HydraComplexModel(*args, **kwargs)

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

  • 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 HydraServer.soap_server.hydra_complexmodels.LoginResponse(*args, **kwargs)
class HydraServer.soap_server.hydra_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 HydraServer.soap_server.hydra_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 HydraServer.soap_server.hydra_complexmodels.NetworkOwner(parent=None)
  • network_id Integer
  • user_id Integer
  • edit Unicode
  • view Unicode)
class HydraServer.soap_server.hydra_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 Decimal(min_occurs=1, default=0)
  • y Decimal(min_occurs=1, default=0)
  • status Unicode(default=’A** pattern=”[AX]”)
  • attributes SpyneArray(ResourceAttr)
  • types SpyneArray(TypeSummary)
  • cr_date Unicode(default=None)
class HydraServer.soap_server.hydra_complexmodels.Note(parent=None)
  • id Integer
  • ref_key Unicode
  • ref_id Integer
  • text Unicode
  • created_by Integer
  • cr_date Unicode
class HydraServer.soap_server.hydra_complexmodels.Perm(parent=None)
  • id Integer
  • name Unicode
  • code Unicode
class HydraServer.soap_server.hydra_complexmodels.Plugin(parent=None)
  • name Unicode
  • location Unicode
  • params SpyneArray(PluginParam)
class HydraServer.soap_server.hydra_complexmodels.PluginParam(parent=None)
  • name Unicode
  • value Unicode
class HydraServer.soap_server.hydra_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 HydraServer.soap_server.hydra_complexmodels.ProjectOwner(parent=None)
  • project_id Integer
  • user_id Integer
  • edit Unicode
  • view Unicode)
class HydraServer.soap_server.hydra_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 HydraServer.soap_server.hydra_complexmodels.Resource(*args, **kwargs)
Superclass for anything which has a layout field:
  • nodes
  • links
  • network
  • scenario
  • project
class HydraServer.soap_server.hydra_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 HydraServer.soap_server.hydra_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 HydraServer.soap_server.hydra_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_frequency: The frequency of the timesteps in a timeseries. Only applicable if the dataset has a type ‘timeseries’

  • 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 HydraServer.soap_server.hydra_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 HydraServer.soap_server.hydra_complexmodels.ResourceGroupDiff(parent=None)
  • scenario_1_items SpyneArray(ResourceGroupItem)
  • scenario_2_items SpyneArray(ResourceGroupItem))
class HydraServer.soap_server.hydra_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 HydraServer.soap_server.hydra_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 HydraServer.soap_server.hydra_complexmodels.ResourceScenarioDiff(parent=None)
  • resource_attr_id Integer(default=None)
  • scenario_1_dataset Dataset
  • scenario_2_dataset Dataset
class HydraServer.soap_server.hydra_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 HydraServer.soap_server.hydra_complexmodels.ResourceTypeDef(*args, **kwargs)
  • ref_key Unicode(default=None)
  • ref_id Integer(default=None)
  • type_id Integer(default=None)
class HydraServer.soap_server.hydra_complexmodels.Role(parent=None)
  • id Integer
  • name Unicode
  • code Unicode
  • roleperms SpyneArray(RolePerm)
  • roleusers SpyneArray(RoleUser)
class HydraServer.soap_server.hydra_complexmodels.RolePerm(parent=None)
  • perm_id Integer
class HydraServer.soap_server.hydra_complexmodels.RoleUser(parent=None)
  • user_id Integer
class HydraServer.soap_server.hydra_complexmodels.Rule(parent=None)
  • id Integer
  • name Unicode
  • description Unicode
  • scenario_id Integer
  • ref_key Unicode
  • ref_id Integer
  • text Unicode
  • cr_date Unicode(default=None)
class HydraServer.soap_server.hydra_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 HydraServer.soap_server.hydra_complexmodels.ScenarioDiff(parent=None)
  • resourcescenarios SpyneArray(ResourceScenarioDiff)
  • groups ResourceGroupDiff
class HydraServer.soap_server.hydra_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 HydraServer.soap_server.hydra_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 HydraServer.soap_server.hydra_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 HydraServer.soap_server.hydra_complexmodels.TypeSummary(parent=None)
  • name Unicode
  • id Integer
  • template_name Unicode
  • template_id Integer
class HydraServer.soap_server.hydra_complexmodels.Unit(parent=None)
  • name Unicode
  • abbr Unicode
  • cf Double
  • lf Double
  • info Unicode
  • dimension Unicode
class HydraServer.soap_server.hydra_complexmodels.User(parent=None)
  • id Integer
  • username Unicode(default=None)
  • display_name Unicode(default=None)
  • password Unicode(default=None)
class HydraServer.soap_server.hydra_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(defult=None)
  • resource_attr_id Integer(default=None)
  • dataset_id Integer(default=None)
  • error_text Unicode(default=None)

API functions

Projects

class HydraServer.soap_server.project.ProjectService

The project SOAP service

static add_project(ctx, project)

Add a new project

Parameters:project (hydra_complexmodels.Project) – The new project to be added. The project does not include networks.
Returns:The project received, but with an ID this time.
Return type:hydra_complexmodels.Project

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.

Parameters:project_id (int) – The ID of the project to delete.
Returns:‘OK’
Return type:string
Raises:ResourceNotFoundError – If the Project is not found.
static get_network_project(ctx, network_id)

Get the project of a specified network

Parameters:network_id (int) – The ID of the network whose project details you want
Returns:The parent project of the specified Network
Return type:hydra_complexmodels.Project
Raises:ResourceNotFoundError – If the Network is not found.
static get_networks(ctx, project_id, include_data)

Get all networks in a project

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

List – All the project’s Networks.

Return type:

hydra_complexmodels.Network

Raises:

ResourceNotFoundError – If the Project is not found.

static get_project(ctx, project_id)

Get an existing Project

Parameters:project_id (int) – The ID of the project to retrieve
Returns:The requested project
Return type:hydra_complexmodels.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.

Parameters:project_name (string) – The name of the project to retrieve
Returns:The requested project
Return type:hydra_complexmodels.Project
Raises:ResourceNotFoundError – If the project is not found.
static get_projects(ctx, user_id)

Get all the projects belonging to a user.

Parameters:user_id (int) – The user ID whose projects you want
Returns:List – The requested projects
Return type:hydra_complexmodels.Project
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!

Parameters:project_id (int) – The ID of the project to purge.
Returns:‘OK’
Return type:string
Raises:ResourceNotFoundError – If the Project is not found.
static update_project(ctx, project)

Update a project

Parameters:project (hydra_complexmodels.Project) – The project to be updated. All the attributes of this project will be used to update the existing project
Returns:The updated project
Return type:hydra_complexmodels.Project
Raises:ResourceNotFoundError – If the project is not found.

Attributes

class HydraServer.soap_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"
}
Parameters:attr (HydraServer.soap_server.hydra_complexmodels.Attr) – An attribute object, as described above.
Returns:An attribute object, similar to the one sent in but with an ID.
Return type:hydra_complexmodels.Attr
static add_attributes(ctx, attrs)

Add multiple generic attributes

Parameters:attrs (List[Attr]) – A list of attribute complex models, as described above.
Returns:A list of attribute complex models, reflecting the ones sent in.
Return type:List[Attr]
static add_group_attribute(ctx, group_id, attr_id, is_var)

Add a resource attribute to a group.

Parameters:
  • 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:

The newly created group attribute

Return type:

HydraServer.soap_server.hydra_complexmodels.ResourceAttr

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.

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

List – All the newly created group attributes

Return type:

HydraServer.soap_server.hydra_complexmodels.ResourceAttr

Raises:

ResourceNotFoundError if the type_id or group_id are not in the DB

Add a resource attribute to a link.

Parameters:
  • 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:

The newly created link attribute

Return type:

HydraServer.soap_server.hydra_complexmodels.ResourceAttr

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.

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

List – All the newly created link attributes

Return type:

HydraServer.soap_server.hydra_complexmodels.ResourceAttr

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.

Parameters:
  • network_id (int) – ID of the network
  • attr_id (int) – ID of the attribute to assign to the network
  • is_var (string) – 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:

A complex model of the newly created resource attribute.

Return type:

HydraServer.soap_server.hydra_complexmodels.ResourceAttr

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.

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

List – All the newly created network attributes

Return type:

HydraServer.soap_server.hydra_complexmodels.ResourceAttr

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.

Parameters:
  • 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:

The newly created node attribute

Return type:

HydraServer.soap_server.hydra_complexmodels.ResourceAttr

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.

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

List – All the newly created node attributes

Return type:

HydraServer.soap_server.hydra_complexmodels.ResourceAttr

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’.

Parameters:attr_id (int) – The ID of the attribute you want to check
Returns:‘OK’ if all is well.
Return type:string
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.

Parameters:
  • resource_attr_id_source (int) – The source resource attribute
  • resource_attr_id_target (int) – The target resource attribute
Returns:

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

Return type:

string

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.

Parameters:
  • resource_attr_a (int) – The ID of the source resoure attribute
  • resource_attr_b (int) – The ID of the target resoure attribute
Returns:

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

Return type:

string

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.

Parameters:
  • network_id (int) – The network you want to delete the mappings from (both from and to)
  • network_2_id (int) – The partner network
Returns:

‘OK’

Return type:

string

static delete_resource_attribute(ctx, resource_attr_id)

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

Parameters:resource_attr_id (int) – ID of the complex model to be deleted
Returns:‘OK’
Return type:unicode
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*

Parameters:resource_attr_id (int) – ID of the complex model to be deleted
Returns:‘OK’
Return type:unicode
Raises:ResourceNotFoundError if the resource_attr_id is not in the DB
static get_all_attributes(ctx)

Get all the attributes in the system

Parameters:None
Returns:A list of attribute complex models
Return type:List[Attr]
static get_all_group_attributes(ctx, network_id, template_id)

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

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

List – The resource attributes of all the groups in the network.

Return type:

HydraServer.soap_server.hydra_complexmodels.ResourceAttr

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

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

List – The resource attributes of all the links in the network.

Return type:

HydraServer.soap_server.hydra_complexmodels.ResourceAttr

static get_all_node_attributes(ctx, network_id, template_id)

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

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

List – The resource attributes of all the nodes in the network.

Return type:

HydraServer.soap_server.hydra_complexmodels.ResourceAttr

static get_attribute(ctx, name, dimension)

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

Parameters:
  • name (unicode) – The name of the attribute
  • dimension (unicode) – The dimension of the attribute
Returns:

An attribute complex model. Returns None if no attribute is found.

Return type:

hydra_complexmodels.Attr

static get_attribute_by_id(ctx, ID)

Get a specific attribute by its ID.

Parameters:ID (int) – The ID of the attribute
Returns:An attribute complex model. Returns None if no attribute is found.
Return type:hydra_complexmodels.Attr
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.
Parameters:attrs (List(Attr) – A list of attribute complex models
Returns:List – List of Attr complex models
Return type:HydraServer.soap_server.hydra_complexmodels.Attr
static get_group_attributes(ctx, group_id, type_id)

Get all a group’s attributes.

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

List – All the group’s attributes

Return type:

HydraServer.soap_server.hydra_complexmodels.ResourceAttr

Raises:

ResourceNotFoundError if the type_id or group_id do not exist.

Get all a link’s attributes.

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

List – All the link’s attributes

Return type:

HydraServer.soap_server.hydra_complexmodels.ResourceAttr

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.

Parameters:
  • network_id (int) – The network you want to check the mappings of (both from and to)
  • network_2_id (int) – The partner network
Returns:

List – All the mappings to and from the network(s) in question.

Return type:

hydra_complexmodels.ResourceAttrMap

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).

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

List – All the network attributes

Return type:

HydraServer.soap_server.hydra_complexmodels.ResourceAttr

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.

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

List – All the node’s attributes

Return type:

HydraServer.soap_server.hydra_complexmodels.ResourceAttr

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..

Parameters:
  • node_id (int) – The node you want to delete the mappings from (both from and to)
  • node_2_id (int) – The partner node
Returns:

List – All the mappings to and from the node(s) in question.

Return type:

hydra_complexmodels.ResourceAttrMap

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.

Parameters:
  • resource_attr_a (int) – The ID of the source resoure attribute
  • resource_attr_b (int) – The ID of the target resoure attribute
Returns:

‘OK’ if all is well.

Return type:

string

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"
}
Parameters:attr (HydraServer.soap_server.hydra_complexmodels.Attr) – An attribute complex model, as described above.
Returns:An attribute complex model, reflecting the one sent in.
Return type:hydra_complexmodels.Attr
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)

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

List – Updated ResourceAttr

Return type:

HydraServer.soap_server.hydra_complexmodels.ResourceAttr

Raises:

ResourceNotFoundError if the resource_attr_id is not in the DB

Scenarios

class HydraServer.soap_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 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 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 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 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_resourcegroup_data(ctx, resourcegroup_id, scenario_id, type_id)

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 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 HydraServer.soap_server.users.UserService

The user soap service

static add_perm(ctx, perm)

Add a new permission

static add_role(ctx, role)

Add a new role.

static add_user(ctx, user)

Add a new user.

static delete_perm(ctx, perm_id)

Delete a permission

static delete_role(ctx, role_id)

Delete a role.

static delete_user(ctx, user_id)

Delete a user.

static get_all_perms(ctx)

Get all permissions

static get_all_roles(ctx)

Get all roles

static get_all_users(ctx)

Get the username & ID of all users.

static get_perm(ctx, perm_id)

Get all permissions

static get_perm_by_code(ctx, perm_code)

Get a permission by its code

static get_role(ctx, role_id)

Get a role by its ID.

static get_role_by_code(ctx, role_code)

Get a role by its code

static get_user_by_name(ctx, username)

Get a user by username

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. @param: user_id

static get_user_roles(ctx, user_id)

Get the roles assigned to a user. @param: user_id

static get_username(ctx, uid)

Add a new user.

static update_role(ctx, role)

Update the role. Used to add permissions and users to a role.

static update_user_display_name(ctx, user)

Update a user’s display name

static update_user_password(ctx, user_id, new_password)

Update a user’s password

Plugins

class HydraServer.soap_server.plugins.PluginService

Plugin SOAP service

static get_plugins(ctx)

Get all available plugins

static run_plugin(ctx, plugin)

Run a plugin

Resource Templates

class HydraServer.soap_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, 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 HydraServer.soap_server.units.UnitService
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_units(ctx, values, unit1, unit2)

Convert a value 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)

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)

Delete a unit from the custom unit collection.

static get_all_dimensions(ctx)

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

static get_dimensions(ctx)

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

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, dimension)

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

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 HydraServer.soap_server.static.FileService

The network SOAP service.

class HydraServer.soap_server.static.ImageService

The network SOAP service.