{{! Copyright (c) Meta Platforms, Inc. and affiliates. 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. }}{{! Reflection functions for clients and services }} {{> common/auto_generated_py}} from thrift.py3.reflection import ( ArgumentSpec as __ArgumentSpec, InterfaceSpec as __InterfaceSpec, MethodSpec as __MethodSpec, NumberType as __NumberType, ) import folly.iobuf as _fbthrift_iobuf {{#program:includeNamespaces}} {{#hasTypes?}} import {{#includeNamespace}}{{value}}.{{/includeNamespace}}types as _{{#includeNamespace}}{{value}}_{{/includeNamespace}}types {{/hasTypes?}} {{/program:includeNamespaces}} import {{#program:py3Namespaces}}{{value}}.{{/program:py3Namespaces}}{{program:name}}.types as _{{#program:py3Namespaces}}{{value}}_{{/program:py3Namespaces}}{{program:name}}_types {{#program:services}} def get_reflection__{{service:name}}(for_clients: bool): spec: __InterfaceSpec = __InterfaceSpec( name="{{service:name}}", methods=None, annotations={ {{#service:annotations}} {{> common/annotation }} {{/service:annotations}} }, ) {{#service:supportedFunctions}} spec.add_method( __MethodSpec.__new__( __MethodSpec, name="{{function:name}}", arguments=( {{#function:args}} __ArgumentSpec.__new__( __ArgumentSpec, name="{{field:name}}", type={{#field:type}}{{> types/python_type}}{{/field:type}}, kind={{#field:type}}{{> types/thrift_number_type}}{{/field:type}}, annotations={ {{#field:annotations}} {{> common/annotation }} {{/field:annotations}} }, ), {{/function:args}} ), result={{#function:return_type}}{{! }}{{#type:void?}}None{{/type:void?}}{{! }}{{#function:stream?}}{{! }}{{> clients/stream_response_class_name}} if for_clients else {{! }}{{> services/stream_response_class_name}}{{! }}{{/function:stream?}}{{! }}{{^type:void?}}{{> types/python_type}}{{/type:void?}}{{! }}{{/function:return_type}}, result_kind={{#function:return_type}}{{> types/thrift_number_type}}{{/function:return_type}}, exceptions=( {{#function:exceptions}} {{#field:type}}{{> types/python_type}}{{/field:type}}, {{/function:exceptions}} ), annotations={ {{#function:annotations}} {{> common/annotation }} {{/function:annotations}} }, ) ) {{/service:supportedFunctions}} return spec {{/program:services}}