Skip to content

Commit

Permalink
feat: added support for PostClientFlow
Browse files Browse the repository at this point in the history
  • Loading branch information
anaik91 committed Aug 16, 2023
1 parent d2db718 commit ecf4b51
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 4 deletions.
2 changes: 1 addition & 1 deletion tools/proxy-endpoint-unifier/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def main():
bundled_proxies = utils.list_dir(proxy_bundle_directory)
for each_bundle in bundled_proxies:
validation = x.validate_api('apis',f"{proxy_bundle_directory}/{each_bundle}") # noqa
if not validation:
if not isinstance(validation, bool):
errors[each_bundle] = validation
result[each_bundle] = validation
print(f"{each_bundle} ==> Validation : {validation}")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
Copyright 2023 Google LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<MessageLogging async="false" continueOnError="false" enabled="true" name="Message-Logging-1">
<DisplayName>Message-Logging-1</DisplayName>
<Syslog>
<Message>Message.id = {request.header.id}</Message>
<Host>IP</Host>
<Port>556</Port>
</Syslog>
</MessageLogging>
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@
<Request/>
<Response/>
</PostFlow>
<PostClientFlow>
<Request/>
<Response>
<Step>
<Name>Message-Logging-1</Name>
</Step>
</Response>
</PostClientFlow>
<Flows/>
<HTTPProxyConnection>
<BasePath>/test-policy-5</BasePath>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,20 @@
</PreFlow>
<PostFlow name="PostFlow">
<Request/>
<Response/>
<Response>
<Step>
<Name>Populate-Cache-1</Name>
</Step>
</Response>
</PostFlow>
<PostClientFlow>
<Request/>
<Response>
<Step>
<Name>Message-Logging-1</Name>
</Step>
</Response>
</PostClientFlow>
<Flows/>
<HTTPProxyConnection>
<BasePath>/test-policy</BasePath>
Expand Down
22 changes: 20 additions & 2 deletions tools/proxy-endpoint-unifier/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,15 @@ def get_all_policies_from_endpoint(endpointData, endpointType):
)
)

if (endpointType == 'ProxyEndpoint' and
'PostClientFlow' in endpointData[endpointType]):
print(endpointData[endpointType].keys())
policies.extend(
get_all_policies_from_flow(
endpointData[endpointType]['PostClientFlow']
)
)

Flows = (
[] if endpointData[endpointType]['Flows'] is None else (
[endpointData[endpointType]['Flows']['Flow']] if isinstance(
Expand Down Expand Up @@ -442,14 +451,23 @@ def merge_proxy_endpoints(api_dict, basepath, pes):
process_steps(each_pe_info['ProxyEndpoint']['PreFlow']['Request'],condition) # noqa
)
merged_pe['ProxyEndpoint']['PreFlow']['Response']['Step'].extend(
process_steps(each_pe_info['ProxyEndpoint']['PreFlow']['Request'],condition) # noqa
process_steps(each_pe_info['ProxyEndpoint']['PreFlow']['Response'],condition) # noqa
)
merged_pe['ProxyEndpoint']['PostFlow']['Request']['Step'].extend(
process_steps(each_pe_info['ProxyEndpoint']['PostFlow']['Request'],condition) # noqa
)
merged_pe['ProxyEndpoint']['PostFlow']['Response']['Step'].extend(
process_steps(each_pe_info['ProxyEndpoint']['PostFlow']['Request'],condition) # noqa
process_steps(each_pe_info['ProxyEndpoint']['PostFlow']['Response'],condition) # noqa
)
if 'PostClientFlow' in each_pe_info['ProxyEndpoint']:
merged_pe['ProxyEndpoint']['PostClientFlow'] = {
'@name': 'PostClientFlow',
'Request': {'Step': []},
'Response': {'Step': []},
}
merged_pe['ProxyEndpoint']['PostClientFlow']['Response']['Step'].extend( # noqa
process_steps(each_pe_info['ProxyEndpoint']['PostClientFlow']['Response'], None) # noqa
)
for each_flow in original_flows:
merged_pe['ProxyEndpoint']['Flows']['Flow'].append(
process_flow(each_flow, condition)
Expand Down

0 comments on commit ecf4b51

Please sign in to comment.