77import time
88from unicodedata import name # enforce a timeout; sleep
99
10- from .utility import (DC_PROVIDERS , EXCLUDED_PATCH_PROPERTIES ,
11- MAJOR_REGIONS , NETWORK_RESOURCES , STATUS_CODES , VALID_SEPARATORS ,
10+ from .utility import (DC_PROVIDERS , EXCLUDED_PATCH_PROPERTIES , MAJOR_REGIONS ,
11+ NETWORK_RESOURCES , STATUS_CODES , VALID_SEPARATORS ,
1212 VALID_SERVICE_PROTOCOLS , Utility , docstring_parameters ,
1313 eprint , http , is_uuidv4 , plural , singular )
1414
@@ -337,9 +337,9 @@ def get_edge_router_data_centers(self, provider: str=None, location_code: str=No
337337
338338 if response_code == STATUS_CODES .codes .OK : # HTTP 200
339339 try :
340- data_centers = json . loads ( response .text )['_embedded' ]['dataCenters' ]
340+ data_centers = response .json ( )['_embedded' ][NETWORK_RESOURCES [ 'data-centers' ]. _embedded ]
341341 except ValueError as e :
342- eprint ( 'ERROR getting data centers' )
342+ logging . error ( 'failed to load data centers response as object from JSON ' )
343343 raise (e )
344344 else :
345345 raise Exception (
@@ -531,11 +531,11 @@ def get_resources(self, type: str, accept: str=None, deleted: bool=False, **kwar
531531 return ([])
532532 # if there is one page of resources
533533 elif total_pages == 1 :
534- all_entities = resources ['_embedded' ][NETWORK_RESOURCES [type ][ 'embedded' ] ]
534+ all_entities = resources ['_embedded' ][NETWORK_RESOURCES [type ]. _embedded ]
535535 # if there are multiple pages of resources
536536 else :
537537 # initialize the list with the first page of resources
538- all_entities = resources ['_embedded' ][NETWORK_RESOURCES [type ][ 'embedded' ] ]
538+ all_entities = resources ['_embedded' ][NETWORK_RESOURCES [type ]. _embedded ]
539539 # append the remaining pages of resources
540540 for page in range (1 ,total_pages ):
541541 try :
@@ -554,7 +554,7 @@ def get_resources(self, type: str, accept: str=None, deleted: bool=False, **kwar
554554 if response_code == STATUS_CODES .codes .OK : # HTTP 200
555555 try :
556556 resources = json .loads (response .text )
557- all_entities .extend (resources ['_embedded' ][NETWORK_RESOURCES [type ][ 'embedded' ] ])
557+ all_entities .extend (resources ['_embedded' ][NETWORK_RESOURCES [type ]. _embedded ])
558558 except ValueError as e :
559559 eprint ('ERROR: failed to load resources object from GET response' )
560560 raise (e )
@@ -909,7 +909,7 @@ def create_endpoint(self, name: str, attributes: list=[], session_identity: str=
909909 started = None
910910 any_in = lambda a , b : any (i in b for i in a )
911911 response_code_symbols = [s .upper () for s in STATUS_CODES ._codes [response_code ]]
912- if any_in (response_code_symbols , NETWORK_RESOURCES ['endpoints' ][ ' create_responses' ] ):
912+ if any_in (response_code_symbols , NETWORK_RESOURCES ['endpoints' ]. create_responses ):
913913 try :
914914 started = json .loads (response .text )
915915 except ValueError as e :
@@ -1016,7 +1016,7 @@ def create_edge_router(self, name: str, attributes: list=[], link_listener: bool
10161016 raise
10171017 any_in = lambda a , b : any (i in b for i in a )
10181018 response_code_symbols = [s .upper () for s in STATUS_CODES ._codes [response_code ]]
1019- if any_in (response_code_symbols , NETWORK_RESOURCES ['edge-routers' ][ ' create_responses' ] ):
1019+ if any_in (response_code_symbols , NETWORK_RESOURCES ['edge-routers' ]. create_responses ):
10201020 try :
10211021 started = json .loads (response .text )
10221022 except ValueError as e :
@@ -1095,7 +1095,7 @@ def create_edge_router_policy(self, name: str, endpoint_attributes: list=[], edg
10951095 raise
10961096 any_in = lambda a , b : any (i in b for i in a )
10971097 response_code_symbols = [s .upper () for s in STATUS_CODES ._codes [response_code ]]
1098- if any_in (response_code_symbols , NETWORK_RESOURCES ['edge-router-policies' ][ ' create_responses' ] ):
1098+ if any_in (response_code_symbols , NETWORK_RESOURCES ['edge-router-policies' ]. create_responses ):
10991099 try :
11001100 started = json .loads (response .text )
11011101 except ValueError as e :
@@ -1249,7 +1249,7 @@ def create_service_simple(self, name: str, client_host_name: str, client_port: i
12491249 raise
12501250 any_in = lambda a , b : any (i in b for i in a )
12511251 response_code_symbols = [s .upper () for s in STATUS_CODES ._codes [response_code ]]
1252- if any_in (response_code_symbols , NETWORK_RESOURCES ['services' ][ ' create_responses' ] ):
1252+ if any_in (response_code_symbols , NETWORK_RESOURCES ['services' ]. create_responses ):
12531253 try :
12541254 started = json .loads (response .text )
12551255 except ValueError as e :
@@ -1346,7 +1346,7 @@ def create_service_policy(self, name: str, services: list, endpoints: list, type
13461346
13471347 any_in = lambda a , b : any (i in b for i in a )
13481348 response_code_symbols = [s .upper () for s in STATUS_CODES ._codes [response_code ]]
1349- if any_in (response_code_symbols , NETWORK_RESOURCES ['service-policies' ][ ' create_responses' ] ):
1349+ if any_in (response_code_symbols , NETWORK_RESOURCES ['service-policies' ]. create_responses ):
13501350 try :
13511351 started = json .loads (response .text )
13521352 except ValueError as e :
@@ -1435,7 +1435,7 @@ def create_service_edge_router_policy(self, name: str, services: list, edge_rout
14351435
14361436 any_in = lambda a , b : any (i in b for i in a )
14371437 response_code_symbols = [s .upper () for s in STATUS_CODES ._codes [response_code ]]
1438- if any_in (response_code_symbols , NETWORK_RESOURCES ['service-edge-router-policies' ][ ' create_responses' ] ):
1438+ if any_in (response_code_symbols , NETWORK_RESOURCES ['service-edge-router-policies' ]. create_responses ):
14391439 try :
14401440 started = json .loads (response .text )
14411441 except ValueError as e :
@@ -1539,7 +1539,7 @@ def create_service_with_configs(self, name: str, intercept_config_data: dict, ho
15391539
15401540 any_in = lambda a , b : any (i in b for i in a )
15411541 response_code_symbols = [s .upper () for s in STATUS_CODES ._codes [response_code ]]
1542- if any_in (response_code_symbols , NETWORK_RESOURCES ['services' ][ ' create_responses' ] ):
1542+ if any_in (response_code_symbols , NETWORK_RESOURCES ['services' ]. create_responses ):
15431543 try :
15441544 started = json .loads (response .text )
15451545 except ValueError as e :
@@ -1857,7 +1857,7 @@ def create_service_advanced(self, name: str, endpoints: list, client_hosts: list
18571857
18581858 any_in = lambda a , b : any (i in b for i in a )
18591859 response_code_symbols = [s .upper () for s in STATUS_CODES ._codes [response_code ]]
1860- if any_in (response_code_symbols , NETWORK_RESOURCES ['services' ][ ' create_responses' ] ):
1860+ if any_in (response_code_symbols , NETWORK_RESOURCES ['services' ]. create_responses ):
18611861 try :
18621862 started = json .loads (response .text )
18631863 except ValueError as e :
@@ -1937,7 +1937,7 @@ def create_app_wan(self, name: str, endpoint_attributes: list=[], service_attrib
19371937 raise
19381938 any_in = lambda a , b : any (i in b for i in a )
19391939 response_code_symbols = [s .upper () for s in STATUS_CODES ._codes [response_code ]]
1940- if any_in (response_code_symbols , NETWORK_RESOURCES ['app-wans' ][ ' create_responses' ] ):
1940+ if any_in (response_code_symbols , NETWORK_RESOURCES ['app-wans' ]. create_responses ):
19411941 try :
19421942 started = json .loads (response .text )
19431943 except ValueError as e :
@@ -2002,7 +2002,7 @@ def get_network_by_name(self,name: str,group: str=None):
20022002 )
20032003 hits = networks ['page' ]['totalElements' ]
20042004 if hits == 1 :
2005- network = networks ['_embedded' ][NETWORK_RESOURCES ['networks' ][ 'embedded' ] ][0 ]
2005+ network = networks ['_embedded' ][NETWORK_RESOURCES ['networks' ]. _embedded ][0 ]
20062006 return (network )
20072007 else :
20082008 raise Exception ("ERROR: failed to find exactly one match for {}" .format (name ))
@@ -2210,7 +2210,6 @@ def wait_for_entity_name_exists(self, entity_name: str, entity_type: str, wait:
22102210 :param: sleep SECONDS polling interval
22112211 :param: progress print a horizontal progress meter as dots, default false
22122212 """
2213-
22142213 now = time .time ()
22152214
22162215 if not wait >= sleep :
0 commit comments