{{! 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 cimport ( MethodSpec as __MethodSpec, ArgumentSpec as __ArgumentSpec, NumberType as __NumberType, ) import folly.iobuf as _fbthrift_iobuf {{#program:includeNamespaces}} {{#hasTypes?}} cimport {{#includeNamespace}}{{value}}.{{/includeNamespace}}{{> common/auto_migrate_prefix}}types as _{{#includeNamespace}}{{value}}_{{/includeNamespace}}types {{/hasTypes?}} {{/program:includeNamespaces}} cimport {{#program:py3Namespaces}}{{value}}.{{/program:py3Namespaces}}{{program:name}}.{{> common/auto_migrate_prefix}}types as _{{#program:py3Namespaces}}{{value}}_{{/program:py3Namespaces}}{{program:name}}_types {{#program:services}} cdef __InterfaceSpec get_reflection__{{service:name}}(bint for_clients): cdef __InterfaceSpec spec = __InterfaceSpec._fbthrift_create( name="{{service:name}}", annotations={ {{#service:annotations}} {{> common/annotation }} {{/service:annotations}} }, ) {{#service:supportedFunctions}} spec.add_method( __MethodSpec._fbthrift_create( name="{{function:name}}", arguments=( {{#function:args}} __ArgumentSpec._fbthrift_create( 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}}