2323import zipfile
2424import requests
2525
26- APIGEE_PROXY_ENDPOINT_LIMIT = 10
26+ APIGEE_PROXY_ENDPOINT_LIMIT = 10
27+
2728
2829def is_token_valid (token ):
2930 """Checks if an access token is valid.
@@ -43,19 +44,21 @@ def is_token_valid(token):
4344 response_json ['email' ] = ''
4445 print (f"Token Validated for user { response_json ['email' ]} " ) # noqa pylint: disable=W1203
4546 return True
46- print (f "Token expired or invalid. Please run export APIGEE_ACCESS_TOKEN=$(gcloud auth print-access-token)" )
47+ print ("Token expired or invalid. Please run export APIGEE_ACCESS_TOKEN=$(gcloud auth print-access-token)" ) # noqa
4748 sys .exit (1 )
4849
50+
4951def parse_config (config_file ):
5052 config = configparser .ConfigParser ()
5153 config .read (config_file )
5254 return config
5355
56+
5457def get_proxy_endpoint_count (cfg ):
5558 try :
5659 proxy_endpoint_count = cfg .getint ('common' , 'proxy_endpoint_count' )
57- if not (proxy_endpoint_count > 0 and proxy_endpoint_count <= APIGEE_PROXY_ENDPOINT_LIMIT ):
58- print (f'ERROR: Proxy Endpoints should be > Zero(0) & { APIGEE_PROXY_ENDPOINT_LIMIT } ' )
60+ if not (proxy_endpoint_count > 0 and proxy_endpoint_count <= APIGEE_PROXY_ENDPOINT_LIMIT ): # noqa
61+ print (f'ERROR: Proxy Endpoints should be > Zero(0) & { APIGEE_PROXY_ENDPOINT_LIMIT } ' ) # noqa
5962 sys .exit (1 )
6063 except ValueError :
6164 print ('proxy_endpoint_count should be a Number' )
@@ -276,7 +279,6 @@ def get_all_policies_from_flow(flow, fault_rule=False): # noqa pylint: disable=
276279 return policies
277280
278281
279-
280282def get_all_policies_from_endpoint (endpointData , endpointType ):
281283 policies = []
282284 policies .extend (
@@ -453,19 +455,15 @@ def process_flow(flow, condition):
453455 dict: processed flow dictionary.
454456 """
455457 processed_flow = flow .copy ()
456-
457458 if flow .get ('Request' , None ) is not None :
458459 Step = flow .get ('Request' , None ).get ('Step' , None )
459- if Step is not None :
460- processed_flow ['Request' ]['Step' ] = process_steps (flow ['Request' ],
461- condition )
460+ if Step is not None :
461+ processed_flow ['Request' ]['Step' ] = process_steps (flow ['Request' ], condition ) # noqa
462462 if flow .get ('Response' , None ) is not None :
463463 Step = flow .get ('Response' , None ).get ('Step' , None )
464464 if Step is not None :
465- processed_flow ['Response' ]['Step' ] = process_steps (flow ['Response' ],
466- condition )
467- processed_flow_with_condition = apply_condition (processed_flow ,
468- condition )
465+ processed_flow ['Response' ]['Step' ] = process_steps (flow ['Response' ], condition ) # noqa
466+ processed_flow_with_condition = apply_condition (processed_flow , condition ) # noqa
469467 return processed_flow_with_condition
470468
471469
@@ -531,7 +529,7 @@ def merge_proxy_endpoints(api_dict, basepath, pes):
531529 merged_pe ['ProxyEndpoint' ]['Description' ] = each_pe_info ['ProxyEndpoint' ]['Description' ] # noqa pylint: disable=C0301
532530 merged_pe ['ProxyEndpoint' ]['FaultRules' ] = each_pe_info ['ProxyEndpoint' ]['FaultRules' ] # noqa pylint: disable=C0301
533531 merged_pe ['ProxyEndpoint' ]['HTTPProxyConnection' ]['BasePath' ] = (basepath if basepath is None else f'/{ basepath } ' ) # noqa pylint: disable=C0301
534- if len (merged_pe ['ProxyEndpoint' ]['HTTPProxyConnection' ]['Properties' ]) != 0 :
532+ if len (merged_pe ['ProxyEndpoint' ]['HTTPProxyConnection' ]['Properties' ]) != 0 : # noqa
535533 merged_pe ['ProxyEndpoint' ]['HTTPProxyConnection' ]['Properties' ] = each_pe_info ['ProxyEndpoint' ]['HTTPProxyConnection' ]['Properties' ] # noqa pylint: disable=C0301
536534 merged_pe ['ProxyEndpoint' ]['HTTPProxyConnection' ]['VirtualHost' ] = each_pe_info ['ProxyEndpoint' ]['HTTPProxyConnection' ]['VirtualHost' ] # noqa pylint: disable=C0301
537535
@@ -564,9 +562,10 @@ def merge_proxy_endpoints(api_dict, basepath, pes):
564562 merged_pe ['ProxyEndpoint' ]['Flows' ]['Flow' ].append (
565563 process_flow (each_flow , condition )
566564 )
567- merged_pe ['ProxyEndpoint' ]['@name' ] = basepath .strip ().replace ('/' ,'' )
565+ merged_pe ['ProxyEndpoint' ]['@name' ] = basepath .strip ().replace ('/' , '' ) # noqa
568566 return merged_pe
569567
568+
570569def copy_folder (src , dst ):
571570 try :
572571 shutil .copytree (src , dst )
0 commit comments