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 ...@@ -7,7 +7,12 @@ from enum import Enum
# Navigation Properties # Navigation Properties
# http://149.210.162.190:81/ImsVersions/4.19.9/html/86d07a57-fa45-835e-d4a2-a789c4acbc96.htm # noqa # http://149.210.162.190:81/ImsVersions/4.19.9/html/86d07a57-fa45-835e-d4a2-a789c4acbc96.htm # noqa
CIRCUIT_PROPERTIES = { 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 # http://149.210.162.190:81/ImsVersions/4.19.9/html/dbc969d0-e735-132e-6281-f724c6d7da64.htm # NOQA
CONTACT_PROPERTIES = { CONTACT_PROPERTIES = {
...@@ -21,22 +26,37 @@ CUSTOMER_PROPERTIES = { ...@@ -21,22 +26,37 @@ CUSTOMER_PROPERTIES = {
'CustomerRelatedContacts': 32768, 'CustomerRelatedContacts': 32768,
'CustomerType': 262144 '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 # http://149.210.162.190:81/ImsVersions/4.19.9/html/2d27d509-77cb-537d-3ffa-796de7e82af8.htm # noqa
NODE_PROPERTIES = { NODE_PROPERTIES = {
'EquipmentDefinition': 16, 'EquipmentDefinition': 16,
'ManagementSystem': 128, 'ManagementSystem': 128,
'Site': 256, 'Site': 256,
'Shelves': 1024,
'Ports': 4096,
'InternalPorts': 8192,
'NodeCity': 32768, 'NodeCity': 32768,
'Order': 67108864, 'Order': 67108864,
'NodeCountry': 1073741824 'NodeCountry': 1073741824
} }
# http://149.210.162.190:81/ImsVersions/4.19.9/html/347cb410-8c05-47bd-ceb0-d1dd05bf98a4.htm # noqa # http://149.210.162.190:81/ImsVersions/4.19.9/html/199f32b5-5104-fec7-8787-0d730113e902.htm # noqa
CITY_PROPERTIES = { PORT_PROPERTIES = {
'Country': 8 'Node': 16,
} 'Shelf': 32,
# http://149.210.162.190:81/ImsVersions/4.19.9/html/a8dc6266-d934-8162-4a55-9e1648187f2c.htm # noqa 'Circuit': 512,
EQUIP_DEF_PROPERTIES = {
'Nodes': 4096
} }
# http://149.210.162.190:81/ImsVersions/4.19.9/html/9c8d50f0-842c-5959-0fa6-14e1720669ec.htm # noqa # http://149.210.162.190:81/ImsVersions/4.19.9/html/9c8d50f0-842c-5959-0fa6-14e1720669ec.htm # noqa
SITE_PROPERTIES = { SITE_PROPERTIES = {
...@@ -81,7 +101,6 @@ class IMSError(Exception): ...@@ -81,7 +101,6 @@ class IMSError(Exception):
class IMS(object): class IMS(object):
TIMEOUT_THRESHOLD = 1200 TIMEOUT_THRESHOLD = 1200
NO_OF_ELEMENTS_PER_ITERATION = 50
PERMITTED_RECONNECT_ATTEMPTS = 3 PERMITTED_RECONNECT_ATTEMPTS = 3
LOGIN_PATH = '/login' LOGIN_PATH = '/login'
IMS_PATH = '/ims' IMS_PATH = '/ims'
...@@ -209,13 +228,14 @@ class IMS(object): ...@@ -209,13 +228,14 @@ class IMS(object):
entity, entity,
filter_string, filter_string,
navigation_properties=None, navigation_properties=None,
use_cache=False): use_cache=False,
step_count=50):
more_to_come = True more_to_come = True
start_entity = 0 start_entity = 0
while more_to_come: while more_to_come:
params = { params = {
'paginatorStartElement': start_entity, 'paginatorStartElement': start_entity,
'paginatorNumberOfElements': IMS.NO_OF_ELEMENTS_PER_ITERATION 'paginatorNumberOfElements': step_count
} }
url = f'{entity}/filtered/{filter_string}' url = f'{entity}/filtered/{filter_string}'
entities = self._get_entity( entities = self._get_entity(
...@@ -226,17 +246,21 @@ class IMS(object): ...@@ -226,17 +246,21 @@ class IMS(object):
more_to_come = False more_to_come = False
if entities: if entities:
more_to_come = \ more_to_come = \
len(entities) >= IMS.NO_OF_ELEMENTS_PER_ITERATION len(entities) >= step_count
start_entity += IMS.NO_OF_ELEMENTS_PER_ITERATION start_entity += step_count
yield from entities yield from entities
def get_all_entities( def get_all_entities(
self, self,
entity, entity,
navigation_properties=None, navigation_properties=None,
use_cache=False): use_cache=False,
step_count=50
):
yield from self.get_filtered_entities( yield from self.get_filtered_entities(
entity, entity,
'Id <> 0', 'Id <> 0',
navigation_properties, navigation_properties,
use_cache) use_cache,
step_count
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment