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.
-
class
HydraServer.soap_server.hydra_complexmodels.
Link
(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)
- 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: 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.
-
static
Networks (Inc nodes & links)¶
General remarks¶
Generally speaking, a network consists of nodes and links. Each node can be connected to other one or several nodes through one or several links. Each link connects exactly two nodes.
-
class
HydraServer.soap_server.network.
NetworkService
¶ The network SOAP service.
-
static
activate_group
(ctx, group_id)¶ Set the status of a group to ‘A’
Parameters: group_id (int) – The resource group to reactivate Returns: ‘OK’ Return type: string Raises: ResourceNotFoundError
– If the resource group is not found.
-
static
activate_link
(ctx, link_id)¶ Set the status of a link to ‘A’
Parameters: link_id (int) – The link to reactivate Returns: ‘OK’ Return type: string Raises: ResourceNotFoundError
– If the link is not found.
-
static
activate_network
(ctx, network_id)¶ Un-Deletes a network. (Set the status to ‘Y’ meaning it’ll be included when you request a project’s networks.
Parameters: network_id (int) – The network to reactivate Returns: ‘OK’ Return type: string Raises: ResourceNotFoundError
– If the network is not found.
-
static
activate_node
(ctx, node_id)¶ Set the status of a node to ‘A’
Un-Deletes a node. (Set the status to ‘Y’ meaning it’ll be included when you request a network.
Parameters: node_id (int) – The node to reactivate Returns: ‘OK’ Return type: string Raises: ResourceNotFoundError
– If the node is not found.
-
static
add_group
(ctx, network_id, group)¶ Add a resourcegroup to a network
Parameters: - network_id (int) – The id of the network to receive the new node
- group (hydra_complexmodels.ResourceGroup) – The group to be added
Returns: The newly added group, complete with an ID
Return type: Raises: ResourceNotFoundError
– If the network is not found
-
static
add_link
(ctx, network_id, link)¶ Add a link to a network
Parameters: - network_id (int) – The id of the network to receive the new link
- link (hydra_complexmodels.Link) – The link to be added (see above for the format)
Returns: The newly added link, complete with an ID
Return type: Raises: ResourceNotFoundError
– If the network is not found
-
static
add_links
(ctx, network_id, links)¶ Add a lost of links to a network
Parameters: - network_id (int) – The id of the network to receive the new link
- link (List(hydra_complexmodels.Link) – A list of the links to be added
Returns: List – The newly added links, each complete with an ID
Return type: Raises: ResourceNotFoundError
– If the network is not found
-
static
add_network
(ctx, net)¶ Takes an entire network complex model and saves it to the DB. This complex model includes links & scenarios (with resource data). Returns the network’s complex model.
As links connect two nodes using the node_ids, if the nodes are new they will not yet have node_ids. In this case, use negative ids as temporary IDS until the node has been given an permanent ID.
All inter-object referencing of new objects should be done using negative IDs in the client.
The returned object will have positive IDS
Parameters: net (hydra_complexmodels.Network) – The entire network complex model structure including nodes, links, scenarios and data Returns: The full network structure, with correct IDs for all resources Return type: hydra_complexmodels.Network
-
static
add_node
(ctx, network_id, node)¶ Add a node to a network:
(Node){ id = 1027 name = "Node 1" description = "Node Description" x = 0.0 y = 0.0 attributes = (ResourceAttrArray){ ResourceAttr[] = (ResourceAttr){ attr_id = 1234 }, (ResourceAttr){ attr_id = 4321 }, } }
Parameters: - network_id (int) – The id of the network to receive the new node
- node (hydra_complexmodels.Node) – The node to be added (see above for the format)
Returns: The newly added node, complete with an ID
Return type: Raises: ResourceNotFoundError
– If the network is not found
-
static
add_nodes
(ctx, network_id, nodes)¶ Add a lost of nodes to a network
Parameters: - network_id (int) – The id of the network to receive the new node
- node (List(hydra_complexmodels.Node) – A list of the nodes to be added
Returns: List – The newly added nodes, each complete with an ID
Return type: Raises: ResourceNotFoundError
– If the network is not found
-
static
clean_up_network
(ctx, network_id)¶ Purge all nodes, links, groups and scenarios from a network which have previously been deleted.
Parameters: network_id (int) – The network to clean up Returns: ‘OK’ Return type: string Raises: ResourceNotFoundError
– If the network is not found
-
static
delete_group
(ctx, group_id)¶ Set the status of a group to ‘X’ :param group_id: The resource group to delete
Returns: ‘OK’ Return type: string Raises: ResourceNotFoundError
– If the resource group is not found
-
static
delete_link
(ctx, link_id)¶ Set the status of a link to ‘X’
Parameters: link_id (int) – The link to delete Returns: ‘OK’ Return type: string Raises: ResourceNotFoundError
– If the link is not found
-
static
delete_network
(ctx, network_id)¶ Set status of network to ‘X’ so it will no longer appear when you retrieve its project. This will not delete the network from the DB. For that use purge_network
Parameters: network_id (int) – The network to delete Returns: ‘OK’ Return type: string Raises: ResourceNotFoundError
– If the network is not found
-
static
delete_node
(ctx, node_id)¶ Set status of node to ‘X’ so it will no longer appear when you retrieve its network. This will not delete the node from the DB. For that use purge_node
Parameters: node_id (int) – The node to delete Returns: ‘OK’ Return type: string Raises: ResourceNotFoundError
– If the node is not found
-
static
get_all_group_data
(ctx, network_id, scenario_id, group_ids, include_metadata)¶ Return all the attributes for all the groups in a given network and a given scenario. Returns a list of ResourceAttr objects, each with a resourcescenario attribute, containing the actual value for the scenario specified.
Parameters: - network_id (int) – The network to search in
- scenario_id (int) – The scenario to search
- group_ids (List(int) – The specific resource groups to search for data in. If not specified, all the groups in the network will be searched.
- include_metadata – (string) (‘Y’ or ‘N’): Default ‘N’. Set to ‘Y’ to return metadata. This may vause a performance hit as metadata is BIG!
Returns: List(ResourceAttr), each with a resourcescenario attribute, containing the actual value for the scenario specified.
-
static
get_all_link_data
(ctx, network_id, scenario_id, link_ids, include_metadata)¶ Return all the attributes for all the links in a given network and a given scenario. Returns a list of ResourceAttr objects, each with a resourcescenario attribute, containing the actual value for the scenario specified.
Parameters: - network_id (int) – The network to search in
- scenario_id (int) – The scenario to search
- link_ids (List(int) – The specific links to search for data in. If not specified, all the links in the network will be searched.
- include_metadata – (string) (‘Y’ or ‘N’): Default ‘N’. Set to ‘Y’ to return metadata. This may vause a performance hit as metadata is BIG!
Returns: List(ResourceAttr), each with a resourcescenario attribute, containing the actual value for the scenario specified.
Raises: ResourceNotFoundError
– If the network or scenario are not found
-
static
get_all_node_data
(ctx, network_id, scenario_id, node_ids, include_metadata)¶ Return all the attributes for all the nodes in a given network and a given scenario.
Parameters: - network_id (int) – The network to search in
- scenario_id (int) – The scenario to search
- node_ids (List(int) – The specific nodes to search for data in. If not specified, all the nodes in the network will be searched.
- include_metadata – (string) (‘Y’ or ‘N’): Default ‘N’. Set to ‘Y’ to return metadata. This may vause a performance hit as metadata is BIG!
Returns: List(ResourceAttr), each with a resourcescenario attribute, containing the actual value for the scenario specified.
Raises: ResourceNotFoundError
– If the network or scenario are not found
-
static
get_all_resource_data
(ctx, scenario_id, include_values, include_metadata, page_start, page_end)¶ Return all the attributes for all the nodes in a given network and a given scenario.
In this function array data and timeseries data are returned as JSON strings.
If your data structure looks like:
H1 H2 H3 1 10 100 2 20 200 3 30 300 4 40 400 Then hydra will provide the data in the following format:
- ‘{
“H1” : {“0”:1, “1”:2, “3”:3, “4”:4},
“H2” : {“0”:10, “1”:20, “3”:30, “4”:40},
“H3” : {“0”:100, “1”:200, “3”:300, “4”:400}
}’
For a timeseries:
Time H1 H2 H3 2014/09/04 16:46:12:00 1 10 100 2014/09/05 16:46:12:00 2 20 200 2014/09/06 16:46:12:00 3 30 300 2014/09/07 16:46:12:00 4 40 400 Then hydra will provide the data in the following format:
- ‘{
“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}
}’
Parameters: - scenario_id (int) – The scenario to search
- include_values (string) – Default ‘N’. Set to ‘Y’ to return the values. This may vause a performance hit as values are BIG!
- include_metadata – (string) (‘Y’ or ‘N’): Default ‘N’. Set to ‘Y’ to return metadata. This may vause a performance hit as metadata is BIG!
- page_start (int) – The start of the search results (allows you to contol the nuber of results)
- page_end (int) – The end of the search results
Returns: List – A list of objects describing datasets specifically designed for efficiency
Return type:
-
static
get_link
(ctx, link_id, scenario_id)¶ Get a link using the link_id. optionally, scenario_id can be included if data is to be included
Parameters: - link_id (int) – The link to retrieve
- scenario_id (int) – Include this if you want to include data with the scenario
Returns: A link complex model, with attributes and data if requested)
Return type: Raises: ResourceNotFoundError
– If the link or scenario is not found
-
static
get_network
(ctx, network_id, include_data, template_id, scenario_ids, summary)¶ Return a whole network as a complex model.
Parameters: - network_id (int) – The ID of the network to retrieve
- include_data (char) – Optional flag to indicate whether to return datasets with the network. Defaults to ‘Y’, but using ‘N’ is much faster.
- template_id (int) – Optional parameter which will only return attributes on the resources that are in this template.
- scenario_ids (List(int) – Optional parameter to indicate which scenarios to return with the network. If left unspecified, all scenarios are returned
- summary (char) – Optional flag to indicate whether attributes are returned with the nodes & links. Seting to ‘Y’ has significant speed improvements at the cost of not retrieving attribute information.
Returns: A network complex model
Return type: Raises: ResourceNotFoundError
– If the network is not found.
-
static
get_network_as_json
(ctx, network_id)¶ Return a whole network as a json string. Used for testing.
Parameters: network_id (int) – The ID of the network to retrieve Returns: A json-encoded representation of the network Return type: string
-
static
get_network_by_name
(ctx, project_id, network_name)¶ Search for a network by its name and return it.
Parameters: - project_id (int) – As network names are only unique within a project, search for the network within the specified project
- network_name (string) – The name of the network
Returns: The entire network structure, no filtering is performed, so all data and attributes are returned
Return type: Raises: ResourceNotFoundError
– If the project or network is not found
-
static
get_network_extents
(ctx, network_id)¶ Given a network, return its maximum extents. This would be the minimum x value of all nodes, the minimum y value of all nodes, the maximum x value of all nodes and maximum y value of all nodes.
Parameters: network_id (int) – The network to get the extents for Returns: the min x, max x, min y, max y of all nodes in the network Return type: NetworkExtents Raises: ResourceNotFoundError
– If the network is not found.
-
static
get_node
(ctx, node_id, scenario_id)¶ Get a node using the node_id. optionally, scenario_id can be included if data is to be included
Parameters: - node_id (int) – The node to retrieve
- scenario_id (int) – Include this if you want to include data with the scenario
Returns: A node complex model, with attributes and data if requested)
Return type: Raises: ResourceNotFoundError
– If the node or scenario is not found
-
static
get_resourcegroup
(ctx, group_id, scenario_id)¶ Get a resourcegroup using the group_id. optionally, scenario_id can be included if data is to be included
Parameters: - group_id (int) – The resource group to retrieve
- scenario_id (int) – Include this if you want to include data with the scenario
Returns: A resource group complex model, with attributes and data if requested)
Return type: Raises: ResourceNotFoundError
– If the group or scenario is not found
-
static
get_resources_of_type
(ctx, network_id, type_id)¶ Return a list of Nodes, Links or ResourceGroups which have the specified type.
Parameters: - network_id (int) – Types of resources in this network
- type_id (int) – Search for resources of this type.
Returns: List – These objects contain the attributes common to all resources, namely: type, id, name, description, attribues and types.
Return type: Raises: ResourceNotFoundError
– If the network or type is not found
-
static
get_scenarios
(ctx, network_id)¶ Get all the scenarios in a given network.
Parameters: network_id (int) – The network from which to retrieve the scenarios Returns: List – All the scenarios in the network Return type: hydra_complexmodels.Scenario Raises: ResourceNotFoundError
– If the network is not found
-
static
network_exists
(ctx, project_id, network_name)¶ Using a network’s name, check if a network exists or not within a project.
Parameters: - project_id (int) – The project in which you are searching
- network_name (string) – The name of the network you are searching for
Returns: ‘Y’ or ‘N’
Return type: Unicode
Raises: ResourceNotFoundError
– If the project is not defined
-
static
purge_group
(ctx, group_id, purge_data)¶ Remove a resource group from the DB completely. If purge data is set to ‘Y’, any data that is unconnected after the removal of the group will be removed also.
Parameters: - group_id (int) – The resource group to remove completely
- purge_data (string) – Any data left unconnected can be left in the DB or deleted with this flag.
Returns: ‘OK’
Return type: string
Raises: ResourceNotFoundError
– If the resource group is not found
-
static
purge_link
(ctx, link_id, purge_data)¶ Remove link from DB completely If there are attributes on the link, use purge_data to try to delete the data. If no other resources link to this data, it will be deleted.
Parameters: link_id (int) – The link to reactivate Returns: ‘OK’ Return type: string Raises: ResourceNotFoundError
– If the link is not found.
-
static
purge_network
(ctx, network_id, purge_data)¶ Remove a network from hydra platform completely.
Parameters: - network_id (int) – The network to remove completely
- purge_data (string) – Any data left unconnected can be left in the DB or deleted with this flag.
Returns: ‘OK’
Return type: string
Raises: ResourceNotFoundError
– If the network is not found
-
static
purge_node
(ctx, node_id, purge_data)¶ - Remove node from DB completely If there are attributes on the node, use purge_data to try to delete the data. If no other resources link to this data, it will be deleted.
Parameters: - node_id (int) – The node to remove completely
- purge_data (string) – Any data left unconnected can be left in the DB or deleted with this flag.
Returns: ‘OK’
Return type: string
Raises: ResourceNotFoundError
– If the node is not found
-
static
update_link
(ctx, link)¶ Update a link.
Parameters: link (hydra_complexmodels.Link) – The link to be updated Returns: The updated link. Return type: hydra_complexmodels.Link Raises: ResourceNotFoundError
– If the link is not found
-
static
update_network
(ctx, net, update_nodes, update_links, update_groups, update_scenarios)¶ Update an entire network. Send a network complex model with updated nodes, links, groups or scenarios. Using flags, tell the function which of these to update.
Parameters: - net (hydra_complexmodels.Network) – A network reflecting an already existing network (must have an ID), which is to be updated
- updated_nodes (char) – Flag to indicated whether the incoming network’s nodes should be updated
- updated_links (char) – Flag to indicated whether the incoming network’s links should be updated
- updated_groups (char) – Flag to indicated whether the incoming network’s resource groups should be updated
- updated_scenarios (char) – Flag to indicated whether the incoming network’s data should be updated
Returns: The updated network, in summarised forms (without data or attributes)
Return type: Raises: ResourceNotFoundError
– If the network does not exist.
-
static
update_node
(ctx, node)¶ Update a node. If new attributes are present, they will be added to the node. The non-presence of attributes does not remove them.
(Node){ id = 1039 name = "Node 1" description = "Node Description" x = 0.0 y = 0.0 status = "A" attributes = (ResourceAttrArray){ ResourceAttr[] = (ResourceAttr){ id = 850 attr_id = 1038 ref_id = 1039 ref_key = "NODE" attr_is_var = True }, (ResourceAttr){ id = 852 attr_id = 1040 ref_id = 1039 ref_key = "NODE" attr_is_var = True }, } }
Parameters: node (hydra_complexmodels.Node) – The node to be updated Returns: The updated node. Return type: hydra_complexmodels.Node Raises: ResourceNotFoundError
– If the node is not found
-
static
validate_network_topology
(ctx, network_id)¶ Check for the presence of orphan nodes in a network. :param network_id: The network to check
Returns: List – IDs of all the orphan nodes in the network Return type: int Raises: ResourceNotFoundError
– If the network is not found
-
static
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: Raises: ResourceNotFoundError
– If the group or attribute do not existHydraError
– 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: Raises: ResourceNotFoundError if the type_id or group_id are not in the DB
-
static
add_link_attribute
(ctx, link_id, attr_id, is_var)¶ 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: Raises: ResourceNotFoundError
– If the link or attribute do not existHydraError
– If this addition causes a duplicate attribute on the link.
-
static
add_link_attrs_from_type
(ctx, type_id, link_id)¶ 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: 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: 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: 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: Raises: ResourceNotFoundError
– If the node or attribute do not existHydraError
– 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: 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:
-
static
get_all_link_attributes
(ctx, network_id, template_id)¶ 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:
-
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:
-
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:
-
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: Raises: ResourceNotFoundError if the type_id or group_id do not exist.
-
static
get_link_attributes
(ctx, link_id, type_id)¶ 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: 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:
-
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: 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: 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:
-
static
get_template_attributes
(ctx, template_id)¶ Get all the attributes in a template. Args
param (int) template_idReturns
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: Raises: ResourceNotFoundError if the resource_attr_id is not in the DB
-
static
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
-
static
get_link_data
(ctx, link_id, scenario_id, type_id)¶ 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
-
static
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
-
static
Plugins¶
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.
-
static
Units and Dimensions¶
-
class
HydraServer.soap_server.units.
UnitService
¶ -
static
add_dimension
(ctx, dimension)¶ Add a physical dimensions (such as
Volume
orSpeed
) 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