Skip to content
Snippets Groups Projects
Commit 5194e847 authored by Robert Latta's avatar Robert Latta
Browse files

added additional navigation properties; added option for setting no. of...

added additional navigation properties; added option for setting no. of records returned on each call
parent 7ea75888
No related branches found
No related tags found
No related merge requests found
......@@ -7,7 +7,12 @@ from enum import Enum
# Navigation Properties
# http://149.210.162.190:81/ImsVersions/4.19.9/html/86d07a57-fa45-835e-d4a2-a789c4acbc96.htm # noqa
CIRCUIT_PROPERTIES = {
'InternalPorts': 1024
'Ports': 512,
'InternalPorts': 1024,
'SubCircuits': 131072,
'PortsFullDetails': 262144,
'PortA': 34359738368,
'PortB': 68719476736
}
# http://149.210.162.190:81/ImsVersions/4.19.9/html/dbc969d0-e735-132e-6281-f724c6d7da64.htm # NOQA
CONTACT_PROPERTIES = {
......@@ -21,22 +26,37 @@ CUSTOMER_PROPERTIES = {
'CustomerRelatedContacts': 32768,
'CustomerType': 262144
}
# http://149.210.162.190:81/ImsVersions/4.19.9/html/347cb410-8c05-47bd-ceb0-d1dd05bf98a4.htm # noqa
CITY_PROPERTIES = {
'Country': 8
}
# http://149.210.162.190:81/ImsVersions/4.19.9/html/a8dc6266-d934-8162-4a55-9e1648187f2c.htm # noqa
EQUIP_DEF_PROPERTIES = {
'Nodes': 4096
}
# http://149.210.162.190:81/ImsVersions/4.19.9/html/f18222e3-e353-0abe-b89c-820db87940ac.htm # noqa
INTERNAL_PORT_PROPERTIES = {
'Node': 8,
'Shelf': 64,
'Circuit': 256,
}
# http://149.210.162.190:81/ImsVersions/4.19.9/html/2d27d509-77cb-537d-3ffa-796de7e82af8.htm # noqa
NODE_PROPERTIES = {
'EquipmentDefinition': 16,
'ManagementSystem': 128,
'Site': 256,
'Shelves': 1024,
'Ports': 4096,
'InternalPorts': 8192,
'NodeCity': 32768,
'Order': 67108864,
'NodeCountry': 1073741824
}
# http://149.210.162.190:81/ImsVersions/4.19.9/html/347cb410-8c05-47bd-ceb0-d1dd05bf98a4.htm # noqa
CITY_PROPERTIES = {
'Country': 8
}
# http://149.210.162.190:81/ImsVersions/4.19.9/html/a8dc6266-d934-8162-4a55-9e1648187f2c.htm # noqa
EQUIP_DEF_PROPERTIES = {
'Nodes': 4096
# http://149.210.162.190:81/ImsVersions/4.19.9/html/199f32b5-5104-fec7-8787-0d730113e902.htm # noqa
PORT_PROPERTIES = {
'Node': 16,
'Shelf': 32,
'Circuit': 512,
}
# http://149.210.162.190:81/ImsVersions/4.19.9/html/9c8d50f0-842c-5959-0fa6-14e1720669ec.htm # noqa
SITE_PROPERTIES = {
......@@ -81,7 +101,6 @@ class IMSError(Exception):
class IMS(object):
TIMEOUT_THRESHOLD = 1200
NO_OF_ELEMENTS_PER_ITERATION = 50
PERMITTED_RECONNECT_ATTEMPTS = 3
LOGIN_PATH = '/login'
IMS_PATH = '/ims'
......@@ -209,13 +228,14 @@ class IMS(object):
entity,
filter_string,
navigation_properties=None,
use_cache=False):
use_cache=False,
step_count=50):
more_to_come = True
start_entity = 0
while more_to_come:
params = {
'paginatorStartElement': start_entity,
'paginatorNumberOfElements': IMS.NO_OF_ELEMENTS_PER_ITERATION
'paginatorNumberOfElements': step_count
}
url = f'{entity}/filtered/{filter_string}'
entities = self._get_entity(
......@@ -226,17 +246,21 @@ class IMS(object):
more_to_come = False
if entities:
more_to_come = \
len(entities) >= IMS.NO_OF_ELEMENTS_PER_ITERATION
start_entity += IMS.NO_OF_ELEMENTS_PER_ITERATION
len(entities) >= step_count
start_entity += step_count
yield from entities
def get_all_entities(
self,
entity,
navigation_properties=None,
use_cache=False):
use_cache=False,
step_count=50
):
yield from self.get_filtered_entities(
entity,
'Id <> 0',
navigation_properties,
use_cache)
use_cache,
step_count
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment