#
# Autogenerated by Thrift
#
# DO NOT EDIT
#  @generated
#

from __future__ import annotations

import typing as _typing

import apache.thrift.metadata.thrift_types as _fbthrift_metadata
import folly.iobuf as _fbthrift_iobuf
from thrift.python.client import (
    AsyncClient as _fbthrift_python_AsyncClient,
    SyncClient as _fbthrift_python_SyncClient,
    Client as _fbthrift_python_Client,
)
from thrift.python.client.omni_client import InteractionMethodPosition as _fbthrift_InteractionMethodPosition, FunctionQualifier as _fbthrift_FunctionQualifier
from thrift.python.common import RpcOptions
import thrift.python.exceptions as _fbthrift_python_exceptions
import thrift.python.types as _fbthrift_python_types
import module.thrift_types
import module.thrift_metadata

class PubSubStreamingService(_fbthrift_python_Client["PubSubStreamingService.Async", "PubSubStreamingService.Sync"]):
    @staticmethod
    def __get_thrift_name__() -> str:
        return "module.PubSubStreamingService"
    
    @staticmethod
    def __get_thrift_uri__() -> _typing.Optional[str]:
        return None
    
    @staticmethod
    def __get_thrift_unstructured_annotations_DEPRECATED__() -> _typing.Mapping[str, str]:
        return {
        }
    
    @staticmethod
    def __get_metadata__() -> _fbthrift_metadata.ThriftMetadata:
        return module.thrift_metadata.gen_metadata_service_PubSubStreamingService()
    
    class Async(_fbthrift_python_AsyncClient):
        @staticmethod
        def __get_thrift_name__() -> str:
            return "module.PubSubStreamingService"
    
        @staticmethod
        def __get_thrift_uri__() -> _typing.Optional[str]:
            return None
    
        @staticmethod
        def __get_metadata__() -> _fbthrift_metadata.ThriftMetadata:
            return module.thrift_metadata.gen_metadata_service_PubSubStreamingService()
    
        async def returnstream(
            self,
            i32_from: int,
            i32_to: int,
            *,
            rpc_options: _typing.Optional[RpcOptions] = None,
        ) -> _typing.AsyncGenerator[int, None]:
            _fbthrift_resp = await self._send_request(
                "PubSubStreamingService",
                "returnstream",
                module.thrift_types._fbthrift_PubSubStreamingService_returnstream_args(
                    i32_from=i32_from,
                    i32_to=i32_to,),
                (module.thrift_types._fbthrift_PubSubStreamingService_returnstream_result, module.thrift_types._fbthrift_PubSubStreamingService_returnstream_result_stream),
                qualifier = _fbthrift_FunctionQualifier.Unspecified,
                uri_or_name="PubSubStreamingService",
                rpc_options=rpc_options,
            )
            _fbthrift_resp, _fbthrift_stream = _fbthrift_resp
            return _fbthrift_stream
    
        async def streamthrows(
            self,
            foo: int,
            *,
            rpc_options: _typing.Optional[RpcOptions] = None,
        ) -> _typing.AsyncGenerator[int, None]:
            _fbthrift_resp = await self._send_request(
                "PubSubStreamingService",
                "streamthrows",
                module.thrift_types._fbthrift_PubSubStreamingService_streamthrows_args(
                    foo=foo,),
                (module.thrift_types._fbthrift_PubSubStreamingService_streamthrows_result, module.thrift_types._fbthrift_PubSubStreamingService_streamthrows_result_stream),
                qualifier = _fbthrift_FunctionQualifier.Unspecified,
                uri_or_name="PubSubStreamingService",
                rpc_options=rpc_options,
            )
            _fbthrift_resp, _fbthrift_stream = _fbthrift_resp
            return _fbthrift_stream
    
        async def servicethrows(
            self,
            foo: int,
            *,
            rpc_options: _typing.Optional[RpcOptions] = None,
        ) -> _typing.AsyncGenerator[int, None]:
            _fbthrift_resp = await self._send_request(
                "PubSubStreamingService",
                "servicethrows",
                module.thrift_types._fbthrift_PubSubStreamingService_servicethrows_args(
                    foo=foo,),
                (module.thrift_types._fbthrift_PubSubStreamingService_servicethrows_result, module.thrift_types._fbthrift_PubSubStreamingService_servicethrows_result_stream),
                qualifier = _fbthrift_FunctionQualifier.Unspecified,
                uri_or_name="PubSubStreamingService",
                rpc_options=rpc_options,
            )
            _fbthrift_resp, _fbthrift_stream = _fbthrift_resp
            if _fbthrift_resp.e is not None:
                raise _fbthrift_resp.e
            return _fbthrift_stream
    
        async def servicethrows2(
            self,
            foo: int,
            *,
            rpc_options: _typing.Optional[RpcOptions] = None,
        ) -> _typing.AsyncGenerator[int, None]:
            _fbthrift_resp = await self._send_request(
                "PubSubStreamingService",
                "servicethrows2",
                module.thrift_types._fbthrift_PubSubStreamingService_servicethrows2_args(
                    foo=foo,),
                (module.thrift_types._fbthrift_PubSubStreamingService_servicethrows2_result, module.thrift_types._fbthrift_PubSubStreamingService_servicethrows2_result_stream),
                qualifier = _fbthrift_FunctionQualifier.Unspecified,
                uri_or_name="PubSubStreamingService",
                rpc_options=rpc_options,
            )
            _fbthrift_resp, _fbthrift_stream = _fbthrift_resp
            if _fbthrift_resp.e1 is not None:
                raise _fbthrift_resp.e1
            if _fbthrift_resp.e2 is not None:
                raise _fbthrift_resp.e2
            return _fbthrift_stream
    
        async def boththrows(
            self,
            foo: int,
            *,
            rpc_options: _typing.Optional[RpcOptions] = None,
        ) -> _typing.AsyncGenerator[int, None]:
            _fbthrift_resp = await self._send_request(
                "PubSubStreamingService",
                "boththrows",
                module.thrift_types._fbthrift_PubSubStreamingService_boththrows_args(
                    foo=foo,),
                (module.thrift_types._fbthrift_PubSubStreamingService_boththrows_result, module.thrift_types._fbthrift_PubSubStreamingService_boththrows_result_stream),
                qualifier = _fbthrift_FunctionQualifier.Unspecified,
                uri_or_name="PubSubStreamingService",
                rpc_options=rpc_options,
            )
            _fbthrift_resp, _fbthrift_stream = _fbthrift_resp
            if _fbthrift_resp.e is not None:
                raise _fbthrift_resp.e
            return _fbthrift_stream
    
        async def responseandstreamstreamthrows(
            self,
            foo: int,
            *,
            rpc_options: _typing.Optional[RpcOptions] = None,
        ) -> _typing.Tuple[int, _typing.AsyncGenerator[int, None]]:
            _fbthrift_resp = await self._send_request(
                "PubSubStreamingService",
                "responseandstreamstreamthrows",
                module.thrift_types._fbthrift_PubSubStreamingService_responseandstreamstreamthrows_args(
                    foo=foo,),
                (module.thrift_types._fbthrift_PubSubStreamingService_responseandstreamstreamthrows_result, module.thrift_types._fbthrift_PubSubStreamingService_responseandstreamstreamthrows_result_stream),
                qualifier = _fbthrift_FunctionQualifier.Unspecified,
                uri_or_name="PubSubStreamingService",
                rpc_options=rpc_options,
            )
            _fbthrift_resp, _fbthrift_stream = _fbthrift_resp
            # shortcut to success path for non-void returns
            if _fbthrift_resp.success is not None:
                return _fbthrift_resp.success, _fbthrift_stream
            raise _fbthrift_python_exceptions.ApplicationError(
                _fbthrift_python_exceptions.ApplicationErrorType.MISSING_RESULT,
                "Empty Response",
            )
    
        async def responseandstreamservicethrows(
            self,
            foo: int,
            *,
            rpc_options: _typing.Optional[RpcOptions] = None,
        ) -> _typing.Tuple[int, _typing.AsyncGenerator[int, None]]:
            _fbthrift_resp = await self._send_request(
                "PubSubStreamingService",
                "responseandstreamservicethrows",
                module.thrift_types._fbthrift_PubSubStreamingService_responseandstreamservicethrows_args(
                    foo=foo,),
                (module.thrift_types._fbthrift_PubSubStreamingService_responseandstreamservicethrows_result, module.thrift_types._fbthrift_PubSubStreamingService_responseandstreamservicethrows_result_stream),
                qualifier = _fbthrift_FunctionQualifier.Unspecified,
                uri_or_name="PubSubStreamingService",
                rpc_options=rpc_options,
            )
            _fbthrift_resp, _fbthrift_stream = _fbthrift_resp
            # shortcut to success path for non-void returns
            if _fbthrift_resp.success is not None:
                return _fbthrift_resp.success, _fbthrift_stream
            if _fbthrift_resp.e is not None:
                raise _fbthrift_resp.e
            raise _fbthrift_python_exceptions.ApplicationError(
                _fbthrift_python_exceptions.ApplicationErrorType.MISSING_RESULT,
                "Empty Response",
            )
    
        async def responseandstreamboththrows(
            self,
            foo: int,
            *,
            rpc_options: _typing.Optional[RpcOptions] = None,
        ) -> _typing.Tuple[int, _typing.AsyncGenerator[int, None]]:
            _fbthrift_resp = await self._send_request(
                "PubSubStreamingService",
                "responseandstreamboththrows",
                module.thrift_types._fbthrift_PubSubStreamingService_responseandstreamboththrows_args(
                    foo=foo,),
                (module.thrift_types._fbthrift_PubSubStreamingService_responseandstreamboththrows_result, module.thrift_types._fbthrift_PubSubStreamingService_responseandstreamboththrows_result_stream),
                qualifier = _fbthrift_FunctionQualifier.Unspecified,
                uri_or_name="PubSubStreamingService",
                rpc_options=rpc_options,
            )
            _fbthrift_resp, _fbthrift_stream = _fbthrift_resp
            # shortcut to success path for non-void returns
            if _fbthrift_resp.success is not None:
                return _fbthrift_resp.success, _fbthrift_stream
            if _fbthrift_resp.e is not None:
                raise _fbthrift_resp.e
            raise _fbthrift_python_exceptions.ApplicationError(
                _fbthrift_python_exceptions.ApplicationErrorType.MISSING_RESULT,
                "Empty Response",
            )
    
        async def returnstreamFast(
            self,
            i32_from: int,
            i32_to: int,
            *,
            rpc_options: _typing.Optional[RpcOptions] = None,
        ) -> _typing.AsyncGenerator[int, None]:
            _fbthrift_resp = await self._send_request(
                "PubSubStreamingService",
                "returnstreamFast",
                module.thrift_types._fbthrift_PubSubStreamingService_returnstreamFast_args(
                    i32_from=i32_from,
                    i32_to=i32_to,),
                (module.thrift_types._fbthrift_PubSubStreamingService_returnstreamFast_result, module.thrift_types._fbthrift_PubSubStreamingService_returnstreamFast_result_stream),
                qualifier = _fbthrift_FunctionQualifier.Unspecified,
                uri_or_name="PubSubStreamingService",
                rpc_options=rpc_options,
            )
            _fbthrift_resp, _fbthrift_stream = _fbthrift_resp
            return _fbthrift_stream
    
    class Sync(_fbthrift_python_SyncClient):
        @staticmethod
        def __get_thrift_name__() -> str:
            return "module.PubSubStreamingService"
    
        @staticmethod
        def __get_thrift_uri__() -> _typing.Optional[str]:
            return None
    
        @staticmethod
        def __get_metadata__() -> _fbthrift_metadata.ThriftMetadata:
            return module.thrift_metadata.gen_metadata_service_PubSubStreamingService()

