qualified_name = "{{program:name}}.{{service:name}}" if qualified_name in metadata_struct.services: return metadata_struct functions = [ {{#service:functions}}{{^function:starts_interaction?}} _fbthrift_metadata.ThriftFunction(name="{{function:name}}", return_type={{> metadata/return_type }}, arguments=[ {{#function:args}} _fbthrift_metadata.ThriftField(id={{field:key}}, type={{#field:type}}{{> metadata/thrift_type }}{{/field:type}}, name="{{field:name}}", is_optional=False, structured_annotations=[ {{#field:structured_annotations}} {{#structured_annotation:const_struct?}}{{#structured_annotation:const}}{{#constant:value}} {{> metadata/const_struct }}, {{/constant:value}}{{/structured_annotation:const}}{{/structured_annotation:const_struct?}} {{/field:structured_annotations}} ]), {{/function:args}} ], exceptions = [ {{#function:exceptions}} _fbthrift_metadata.ThriftField(id={{field:key}}, type={{#field:type}}{{> metadata/thrift_type }}{{/field:type}}, name="{{field:name}}", is_optional=False, structured_annotations=[ {{#field:structured_annotations}} {{#structured_annotation:const_struct?}}{{#structured_annotation:const}}{{#constant:value}} {{> metadata/const_struct }}, {{/constant:value}}{{/structured_annotation:const}}{{/structured_annotation:const_struct?}} {{/field:structured_annotations}} ]), {{/function:exceptions}} ], is_oneway={{#function:oneway?}}True{{/function:oneway?}}{{^function:oneway?}}False{{/function:oneway?}}, structured_annotations=[ {{#function:structured_annotations}} {{#structured_annotation:const_struct?}}{{#structured_annotation:const}}{{#constant:value}} {{> metadata/const_struct }}, {{/constant:value}}{{/structured_annotation:const}}{{/structured_annotation:const_struct?}} {{/function:structured_annotations}} ]), {{/function:starts_interaction?}}{{/service:functions}} ] service_dict = dict(metadata_struct.services) service_dict[qualified_name] = _fbthrift_metadata.ThriftService(name=qualified_name, functions=functions, {{#service:extends?}}{{#service:extends}}parent="{{service:program_name}}.{{service:name}}",{{/service:extends}}{{/service:extends?}} structured_annotations=[ {{#service:structured_annotations}} {{#structured_annotation:const_struct?}}{{#structured_annotation:const}}{{#constant:value}} {{> metadata/const_struct }}, {{/constant:value}}{{/structured_annotation:const}}{{/structured_annotation:const_struct?}} {{/service:structured_annotations}} ]) new_struct = metadata_struct(services=service_dict) {{#service:extends?}}{{#service:extends}} new_struct = {{#service:external_program?}}{{service:module_path}}.thrift_metadata.{{/service:external_program?}}_fbthrift_gen_metadata_service_{{service:name}}(new_struct) {{/service:extends}}{{/service:extends?}} {{#service:functions}}{{^function:starts_interaction?}} {{#function:args}} {{#field:type}}{{> metadata/recursive_call }} # {{field:name}}{{/field:type}} {{/function:args}} {{#function:exceptions}} {{#field:type}}{{> metadata/recursive_call }} # {{field:name}}{{/field:type}} {{/function:exceptions}} {{#function:return_type}} {{> metadata/recursive_call }}{{! }}{{#function:stream?}}{{#function:stream_elem_type}}{{> metadata/recursive_call }}{{/function:stream_elem_type}} # elem {{#function:stream_first_response_type}}{{> metadata/recursive_call }}{{/function:stream_first_response_type}} # response {{/function:stream?}}{{! }}{{#function:sink?}}{{#function:sink_elem_type}}{{> metadata/recursive_call }}{{/function:sink_elem_type}} # elem {{#function:sink_final_response_type}}{{> metadata/recursive_call }}{{/function:sink_final_response_type}} # final response {{#function:sink_first_response_type}}{{> metadata/recursive_call }}{{/function:sink_first_response_type}} # first response {{/function:sink?}}{{! }} # return value {{/function:return_type}} {{/function:starts_interaction?}}{{/service:functions}} return new_struct