from PLC.Faults import *
from PLC.Method import Method
from PLC.Parameter import Parameter, Mixed
+from PLC.Filter import Filter
from PLC.AddressTypes import AddressType, AddressTypes
from PLC.Auth import Auth
class GetAddressTypes(Method):
"""
- Get an array of structs containing details about valid address
- types. If address_type_id_or_name_list is specified, only the
- specified address types will be queried.
+ Returns an array of structs containing details about address
+ types. If address_type_filter is specified and is an array of
+ address type identifiers, or a struct of address type attributes,
+ only address types matching the filter will be returned.
"""
roles = ['admin', 'pi', 'user', 'tech']
accepts = [
Auth(),
- [Mixed(AddressType.fields['address_type_id'],
- AddressType.fields['name'])]
+ Mixed([Mixed(AddressType.fields['address_type_id'],
+ AddressType.fields['name'])],
+ Filter(AddressType.fields))
]
returns = [AddressType.fields]
- def call(self, auth, address_type_id_or_name_list = None):
- address_types = AddressTypes(self.api, address_type_id_or_name_list).values()
-
- return address_types
+ def call(self, auth, address_type_filter = None):
+ return AddressTypes(self.api, address_type_filter).values()
from PLC.Faults import *
from PLC.Method import Method
from PLC.Parameter import Parameter, Mixed
+from PLC.Filter import Filter
from PLC.Addresses import Address, Addresses
from PLC.Auth import Auth
class GetAddresses(Method):
"""
- Get an array of structs containing details about addresses. If
- address_id_list is specified, only the specified addresses will be
- queried.
+ Returns an array of structs containing details about addresses. If
+ address_filter is specified and is an array of address
+ identifiers, or a struct of address attributes, only addresses
+ matching the filter will be returned.
"""
roles = ['admin', 'pi', 'user', 'tech']
accepts = [
Auth(),
- [Address.fields['address_id']],
+ Mixed([Address.fields['address_id']],
+ Filter(Address.fields))
]
returns = [Address.fields]
- def call(self, auth, address_id_list = None):
- return Addresses(self.api, address_id_list).values()
+ def call(self, auth, address_filter = None):
+ return Addresses(self.api, address_filter).values()
class GetBootStates(Method):
"""
- Returns a list of all valid node boot states.
+ Returns an array of all valid node boot states.
"""
roles = ['admin', 'pi', 'user', 'tech']
from PLC.Faults import *
from PLC.Method import Method
from PLC.Parameter import Parameter, Mixed
+from PLC.Filter import Filter
from PLC.ConfFiles import ConfFile, ConfFiles
from PLC.Auth import Auth
class GetConfFiles(Method):
"""
- Returns an array of structs containing details about node
- configuration files. If conf_file_ids is specified, only the
- specified configuration files will be queried.
+ Returns an array of structs containing details about configuration
+ files. If conf_file_filter is specified and is an array of
+ configuration file identifiers, or a struct of configuration file
+ attributes, only configuration files matching the filter will be
+ returned.
"""
roles = ['admin']
accepts = [
Auth(),
- [ConfFile.fields['conf_file_id']]
+ Mixed([ConfFile.fields['conf_file_id']],
+ Filter(ConfFile.fields))
]
returns = [ConfFile.fields]
- def call(self, auth, conf_file_ids = None):
- return ConfFiles(self.api, conf_file_ids).values()
+ def call(self, auth, conf_file_filter = None):
+ return ConfFiles(self.api, conf_file_filter).values()
from PLC.Faults import *
from PLC.Method import Method
from PLC.Parameter import Parameter, Mixed
+from PLC.Filter import Filter
from PLC.Auth import Auth
from PLC.ForeignNodes import ForeignNode, ForeignNodes
-class GetForeignNodes (Method):
+class GetForeignNodes(Method):
"""
- returns information on foreign nodes
+ Returns an array of structs containing details about foreign
+ nodes. If foreign_node_filter is specified and is an array of
+ foreign node identifiers or hostnames, or a struct of foreign node
+ attributes, only foreign nodes matching the filter will be
+ returned.
"""
roles = ['admin']
- accepts = [ Auth(),
- [ Mixed(ForeignNode.fields['node_id'],
- ForeignNode.fields['hostname'])]
- ]
+ accepts = [
+ Auth(),
+ Mixed([Mixed(ForeignNode.fields['node_id'],
+ ForeignNode.fields['hostname'])],
+ Filter(ForeignNode.fields))
+ ]
- returns = [ ForeignNode.fields]
+ returns = [ForeignNode.fields]
- def call (self, auth, foreign_id_or_hostname_list = None):
-
- return ForeignNodes (self.api, foreign_id_or_hostname_list).values()
-
+ def call(self, auth, foreign_node_filter = None):
+ return ForeignNodes(self.api, foreign_node_filter).values()
class GetKeyTypes(Method):
"""
- Returns a list of all valid key types.
+ Returns an array of all valid key types.
"""
roles = ['admin', 'pi', 'user', 'tech']
class GetKeys(Method):
"""
- Return an array of structs containing details about keys. If
- key_id_list is specified, only the specified keys will be queried.
+ Returns an array of structs containing details about keys. If
+ key_ids is specified, only the specified keys will be queried.
Admin may query all keys. Non-admins may only query their own
keys.
from PLC.Faults import *
from PLC.Method import Method
from PLC.Parameter import Parameter, Mixed
+from PLC.Filter import Filter
from PLC.Auth import Auth
from PLC.NodeGroups import NodeGroup, NodeGroups
class GetNodeGroups(Method):
"""
- Returns an array of structs containing details about all node
- groups. If nodegroup_id_or_name_list is specified, only the
- specified node groups will be queried.
+ Returns an array of structs containing details about node groups.
+ If nodegroup_filter is specified and is an array of node group
+ identifiers or names, or a struct of node group attributes, only
+ node groups matching the filter will be returned.
"""
roles = ['admin', 'pi', 'user', 'tech']
accepts = [
Auth(),
- [Mixed(NodeGroup.fields['nodegroup_id'],
- NodeGroup.fields['name'])]
+ Mixed([Mixed(NodeGroup.fields['nodegroup_id'],
+ NodeGroup.fields['name'])],
+ Filter(NodeGroup.fields))
]
returns = [NodeGroup.fields]
- def call(self, auth, nodegroup_id_or_name_list = None):
- return NodeGroups(self.api, nodegroup_id_or_name_list).values()
+ def call(self, auth, nodegroup_filter = None):
+ return NodeGroups(self.api, nodegroup_filter).values()
from PLC.Faults import *
from PLC.Method import Method
from PLC.Parameter import Parameter, Mixed
+from PLC.Filter import Filter
from PLC.NodeNetworks import NodeNetwork, NodeNetworks
from PLC.Auth import Auth
class GetNodeNetworks(Method):
"""
- Return an array of structs contain details about node network
- interfaces. If nodenetwork_id_or_ip_list is specified, only
- the specified node network interfaces will be queried.
+ Returns an array of structs containing details about node network
+ interfacess. If nodenetworks_filter is specified and is an array
+ of node network identifiers, or a struct of node network
+ attributes, only node network interfaces matching the filter will
+ be returned.
"""
roles = ['admin', 'pi', 'user', 'tech']
accepts = [
Auth(),
- [Mixed(NodeNetwork.fields['nodenetwork_id'],
- NodeNetwork.fields['ip'])]
+ Mixed([NodeNetwork.fields['nodenetwork_id']],
+ Filter(NodeNetwork.fields))
]
returns = [NodeNetwork.fields]
- def call(self, auth, nodenetwork_id_or_ip_list = None):
- return NodeNetworks(self.api, nodenetwork_id_or_ip_list).values()
+ def call(self, auth, nodenetwork_filter = None):
+ return NodeNetworks(self.api, nodenetwork_filter).values()
from PLC.Faults import *
from PLC.Method import Method
from PLC.Parameter import Parameter, Mixed
+from PLC.Filter import Filter
from PLC.Nodes import Node, Nodes
from PLC.Auth import Auth
class GetNodes(Method):
"""
- Return an array of structs containing details about nodes. If
- node_id_or_hostname_list is specified, only the specified nodes
- will be queried.
+ Returns an array of structs containing details about nodes. If
+ node_filter is specified and is an array of node identifiers or
+ hostnames, or a struct of node attributes, only nodes matching the
+ filter will be returned.
Some fields may only be viewed by admins.
"""
accepts = [
Auth(),
- [Mixed(Node.fields['node_id'],
- Node.fields['hostname'])],
+ Mixed([Mixed(Node.fields['node_id'],
+ Node.fields['hostname'])],
+ Filter(Node.fields))
]
returns = [Node.fields]
- def call(self, auth, node_id_or_hostname_list = None):
+ def call(self, auth, node_filter = None):
# Get node information
- nodes = Nodes(self.api, node_id_or_hostname_list).values()
+ nodes = Nodes(self.api, node_filter).values()
# Remove admin only fields
if 'admin' not in self.caller['roles']:
from PLC.Faults import *
from PLC.Method import Method
from PLC.Parameter import Parameter, Mixed
+from PLC.Filter import Filter
from PLC.PCUs import PCU, PCUs
from PLC.Auth import Auth
class GetPCUs(Method):
"""
- Return an array of structs containing details about PCUs. If
- pcu_id_list is specified, only the specified PCUs will be queried.
+ Returns an array of structs containing details about power control
+ units (PCUs). If pcu_filter is specified and is an array of PCU
+ identifiers, or a struct of PCU attributes, only PCUs matching the
+ filter will be returned.
Admin may query all PCUs. Non-admins may only query the PCUs at
their sites.
accepts = [
Auth(),
- [PCU.fields['pcu_id']]
+ Mixed([PCU.fields['pcu_id']],
+ Filter(PCU.fields))
]
returns = [PCU.fields]
- def call(self, auth, pcu_ids = None):
+ def call(self, auth, pcu_filter = None):
# If we are not admin, make sure to only return our own PCUs
if 'admin' not in self.caller['roles']:
# Get list of PCUs that we are able to view
for site in sites:
valid_pcu_ids += site['pcu_ids']
- pcu_ids = set(pcu_ids).intersection(valid_pcu_ids)
- if not pcu_ids:
+ if not valid_pcu_ids:
return []
- return PCUs(self.api, pcu_ids).values()
+ if pcu_filter is None:
+ pcu_filter = valid_pcu_ids
+
+ pcus = PCUs(self.api, pcu_filter).values()
+
+ # Filter out PCUs that are not viewable
+ if 'admin' not in self.caller['roles']:
+ pcus = filter(lambda pcu: pcu['pcu_id'] in valid_pcu_ids, pcus)
+
+ return pcus
from PLC.Faults import *
from PLC.Method import Method
from PLC.Parameter import Parameter, Mixed
+from PLC.Filter import Filter
from PLC.Auth import Auth
from PLC.Peers import Peer, Peers
class GetPeers (Method):
"""
- returns information on known peers
+ Returns an array of structs containing details about peers. If
+ person_filter is specified and is an array of peer identifiers or
+ peer names, or a struct of peer attributes, only peers matching
+ the filter will be returned.
"""
roles = ['admin']
- accepts = [Auth(),
- [Mixed(Peer.fields['peer_id'],
- Peer.fields['peername'])],
- ]
+ accepts = [
+ Auth(),
+ Mixed([Mixed(Peer.fields['peer_id'],
+ Peer.fields['peername'])],
+ Filter(Peer.fields))
+ ]
returns = [Peer.fields]
- def call (self, auth, peer_id_or_peername_list = None):
-
- return Peers (self.api, peer_id_or_peername_list).values()
+ def call (self, auth, peer_filter = None):
+ return Peers(self.api, peer_filter).values()
from PLC.Faults import *
from PLC.Method import Method
from PLC.Parameter import Parameter, Mixed
+from PLC.Filter import Filter
from PLC.Persons import Person, Persons
from PLC.Auth import Auth
class GetPersons(Method):
"""
- Return an array of structs containing details about accounts. If
- person_id_or_email_list is specified, only the specified accounts
- will be queried.
+ Returns an array of structs containing details about users. If
+ person_filter is specified and is an array of user identifiers or
+ usernames, or a struct of user attributes, only users matching the
+ filter will be returned.
Users and techs may only retrieve details about themselves. PIs
may retrieve details about themselves and others at their
accepts = [
Auth(),
- [Mixed(Person.fields['person_id'],
- Person.fields['email'])],
- Parameter([str], 'List of fields to return')
+ Mixed([Mixed(Person.fields['person_id'],
+ Person.fields['email'])],
+ Filter(Person.fields))
]
# Filter out password field
return_fields = dict(filter(can_return, Person.fields.items()))
returns = [return_fields]
- def call(self, auth, person_id_or_email_list = None):
+ def call(self, auth, person_filter = None):
# If we are not admin, make sure to only return viewable accounts
if 'admin' not in self.caller['roles']:
# Get accounts that we are able to view
if not valid_person_ids:
return []
- if not person_id_or_email_list:
- person_id_or_email_list = valid_person_ids
+ if person_filter is None:
+ person_filter = valid_person_ids
- persons = Persons(self.api, person_id_or_email_list).values()
+ persons = Persons(self.api, person_filter).values()
# Filter out accounts that are not viewable
if 'admin' not in self.caller['roles']:
from PLC.Method import Method
from PLC.Parameter import Parameter, Mixed
+from PLC.Filter import Filter
from PLC.Auth import Auth
from PLC.Sites import Site, Sites
accepts = [
Auth(),
- [Mixed(Site.fields['site_id'],
- Site.fields['login_base'])]
+ Mixed([Mixed(Site.fields['site_id'],
+ Site.fields['login_base'])],
+ Filter(Site.fields))
]
returns = [Site.fields]
object_type = 'Site'
object_ids = []
- def call(self, auth, site_id_or_login_base_list = None):
- return Sites(self.api, site_id_or_login_base_list).values()
+ def call(self, auth, site_filter = None):
+ return Sites(self.api, site_filter).values()
from PLC.Method import Method
from PLC.Parameter import Parameter, Mixed
+from PLC.Filter import Filter
from PLC.Auth import Auth
from PLC.SliceAttributeTypes import SliceAttributeType, SliceAttributeTypes
accepts = [
Auth(),
- [Mixed(SliceAttributeType.fields['attribute_type_id'],
- SliceAttributeType.fields['name'])],
+ Mixed([Mixed(SliceAttributeType.fields['attribute_type_id'],
+ SliceAttributeType.fields['name'])],
+ Filter(SliceAttributeType.fields))
]
returns = [SliceAttributeType.fields]
- def call(self, auth, attribute_type_id_or_name_list = None):
- return SliceAttributeTypes(self.api, attribute_type_id_or_name_list).values()
+ def call(self, auth, attribute_type_filter = None):
+ return SliceAttributeTypes(self.api, attribute_type_filter).values()
from PLC.Faults import *
from PLC.Method import Method
from PLC.Parameter import Parameter, Mixed
+from PLC.Filter import Filter
from PLC.SliceAttributes import SliceAttribute, SliceAttributes
from PLC.Sites import Site, Sites
from PLC.Slices import Slice, Slices
-from PLC.Nodes import Node, Nodes
from PLC.Auth import Auth
class GetSliceAttributes(Method):
accepts = [
Auth(),
- [SliceAttribute.fields['slice_attribute_id']],
+ Mixed([SliceAttribute.fields['slice_attribute_id']],
+ Filter(SliceAttribute.fields))
]
returns = [SliceAttribute.fields]
- def call(self, auth, slice_attribute_ids = None):
+ def call(self, auth, slice_attribute_filter = None):
# If we are not admin, make sure to only return our own slice
# and sliver attributes.
if 'admin' not in self.caller['roles']:
for slice in slices:
valid_slice_attribute_ids += slice['slice_attribute_ids']
- slice_attribute_ids = set(slice_attribute_ids).intersection(valid_slice_attribute_ids)
- if not slice_attribute_ids:
+ if not valid_slice_attribute_ids:
return []
- return SliceAttributes(self.api, slice_attribute_ids).values()
+ if slice_attribute_filter is None:
+ slice_attribute_filter = valid_slice_attribute_ids
+
+ slice_attributes = SliceAttributes(self.api, slice_attribute_filter).values()
+
+ # Filter out slice attributes that are not viewable
+ if 'admin' not in self.caller['roles']:
+ slice_attributes = filter(lambda slice_attribute: \
+ slice_attribute['slice_attribute_id'] in valid_slice_attribute_ids,
+ slice_attributes)
+
+ return slice_attributes
from PLC.Method import Method
from PLC.Parameter import Parameter, Mixed
+from PLC.Filter import Filter
from PLC.Auth import Auth
from PLC.Slices import Slice, Slices
class GetSlices(Method):
"""
- Return an array of structs containing details about slices. If
- slice_id_or_name_list is specified, only the specified slices will
- be queried.
+ Returns an array of structs containing details about slices. If
+ slice_filter is specified and is an array of slice identifiers or
+ slice names, or a struct of slice attributes, only slices matching
+ the filter will be returned.
Users may only query slices of which they are members. PIs may
query any of the slices at their sites. Admins may query any
accepts = [
Auth(),
- [Mixed(Slice.fields['slice_id'],
- Slice.fields['name'])]
+ Mixed([Mixed(Slice.fields['slice_id'],
+ Slice.fields['name'])],
+ Filter(Slice.fields))
]
returns = [Slice.fields]
- def call(self, auth, slice_id_or_name_list = None):
+ def call(self, auth, slice_filter = None):
# If we are not admin, make sure to return only viewable
# slices.
if 'admin' not in self.caller['roles']:
if not valid_slice_ids:
return []
- if not slice_id_or_name_list:
- slice_id_or_name_list = valid_slice_ids
+ if slice_filter is None:
+ slice_filter = valid_slice_ids
- slices = Slices(self.api, slice_id_or_name_list).values()
+ slices = Slices(self.api, slice_filter).values()
# Filter out slices that are not viewable
if 'admin' not in self.caller['roles']: