django_socio_grpc.protobuf.proto_classes
Module Contents
Classes
This class is used to represent a comment in a proto file. It allows adding a comment in a serializer field help_text. |
|
Represents a field in a proto message. |
|
Represents a proto message with its fields and comments |
|
Represent a RPC method in a service |
|
Represents a service in a proto file |
|
Mixin to convert a class to a ProtoField |
Functions
Return the proto type of a field, fields can either implement a |
Data
API
- django_socio_grpc.protobuf.proto_classes.logger
‘getLogger(…)’
- class django_socio_grpc.protobuf.proto_classes.ProtoComment(comments)
This class is used to represent a comment in a proto file. It allows adding a comment in a serializer field help_text.
Initialization
- __iter__()
- __bool__()
- class django_socio_grpc.protobuf.proto_classes.ProtoField
Represents a field in a proto message.
{comments} {cardinality} {field_type} {name} = {index};
- field_type: Union[str, ProtoMessage, ProtoEnum]
None
- cardinality: django_socio_grpc.protobuf.typing.FieldCardinality
None
- classmethod _get_cardinality(field: rest_framework.serializers.Field)
- classmethod from_field_dict(field_dict: django_socio_grpc.protobuf.typing.FieldDict) django_socio_grpc.protobuf.proto_classes.ProtoField
- classmethod from_field_dict_handle_str_field_type(field_type: str, field_name: str, cardinality: django_socio_grpc.protobuf.typing.FieldCardinality)
- classmethod from_field(field: rest_framework.serializers.Field, to_message: collections.abc.Callable = None, parent_serializer: rest_framework.serializers.Serializer = None, name_if_recursive: str = None) django_socio_grpc.protobuf.proto_classes.ProtoField
to_message, parent_serializer, name_if_recursive only used if field is ListSerializer with a child being a Serializer
- classmethod get_field_comments(field: rest_framework.serializers.Field)
- classmethod from_serializer(field: rest_framework.serializers.Serializer, to_message: collections.abc.Callable, parent_serializer: rest_framework.serializers.Serializer = None, name_if_recursive: str = None) django_socio_grpc.protobuf.proto_classes.ProtoField
Create a ProtoField from a Serializer, which will be converted to a ProtoMessage with
to_message
- classmethod _extract_method_info(method)
- classmethod _from_serializer_method_field(field: rest_framework.serializers.SerializerMethodField) django_socio_grpc.protobuf.proto_classes.ProtoField
- class django_socio_grpc.protobuf.proto_classes.ProtoEnumLocations
Bases:
enum.Enum- MESSAGE
1
- GLOBAL
2
- class django_socio_grpc.protobuf.proto_classes.ProtoEnum
-
- location: django_socio_grpc.protobuf.proto_classes.ProtoEnumLocations
None
- static get_enum_from_annotation(field: rest_framework.serializers.ChoiceField)
- __eq__(other)
- __hash__()
- class django_socio_grpc.protobuf.proto_classes.ProtoMessage
Represents a proto message with its fields and comments
{comments} message {name} { [{fields}] }
- fields: list[django_socio_grpc.protobuf.proto_classes.ProtoField]
‘dataclass_field(…)’
- get_all_messages() dict[str, django_socio_grpc.protobuf.proto_classes.ProtoMessage]
- set_indices(indices: dict[int, str]) None
Set the field index that is writed in the proto file while trying to keep the same order that the one passed in the incides parameter :param indices: dictionnary mapping the field number with the field name that we want to keep order too. Usually it come from the lecture of the previous proto file before it is generated again
- classmethod create(value: type[rest_framework.serializers.BaseSerializer] | list[django_socio_grpc.protobuf.typing.FieldDict] | str | None, name: str) Union[django_socio_grpc.protobuf.proto_classes.ProtoMessage, str]
- classmethod from_field_dicts(fields: list[django_socio_grpc.protobuf.typing.FieldDict], name: str) django_socio_grpc.protobuf.proto_classes.ProtoMessage
- classmethod from_serializer(serializer: type[rest_framework.serializers.BaseSerializer], name: str | None = None) django_socio_grpc.protobuf.proto_classes.ProtoMessage
- classmethod skip_field(field: rest_framework.serializers.Field | rest_framework.serializers.BaseSerializer, pk_name: str) bool
- __getitem__(key: str) django_socio_grpc.protobuf.proto_classes.ProtoField
- class django_socio_grpc.protobuf.proto_classes.RequestProtoMessage
Bases:
django_socio_grpc.protobuf.proto_classes.ProtoMessage
- class django_socio_grpc.protobuf.proto_classes.ResponseProtoMessage
Bases:
django_socio_grpc.protobuf.proto_classes.ProtoMessage
- django_socio_grpc.protobuf.proto_classes.EmptyMessage
‘ProtoMessage(…)’
- django_socio_grpc.protobuf.proto_classes.StructMessage
‘ProtoMessage(…)’
- class django_socio_grpc.protobuf.proto_classes.ProtoRpc
Represent a RPC method in a service
rpc {name}({request_stream?} {request.name}) returns ({response_stream?} {response.name}) {}- request: django_socio_grpc.protobuf.proto_classes.ProtoMessage | str
None
- response: django_socio_grpc.protobuf.proto_classes.ProtoMessage | str
None
- get_all_messages() dict[str, django_socio_grpc.protobuf.proto_classes.ProtoMessage]
- class django_socio_grpc.protobuf.proto_classes.ProtoService
Represents a service in a proto file
service {name} { [{rpcs}] }
- rpcs: list[django_socio_grpc.protobuf.proto_classes.ProtoRpc]
‘dataclass_field(…)’
- add_rpc(rpc: django_socio_grpc.protobuf.proto_classes.ProtoRpc)
- get_all_messages() dict[str, django_socio_grpc.protobuf.proto_classes.ProtoMessage]
- django_socio_grpc.protobuf.proto_classes.get_proto_type(field: django.db.models.Field | rest_framework.serializers.Field, default='string') str
Return the proto type of a field, fields can either implement a
proto_typeattribute or be a subclass of a known field type.
- django_socio_grpc.protobuf.proto_classes.FIELDS_TO_PROTO_TYPES
None
- django_socio_grpc.protobuf.proto_classes.PRIMITIVE_TYPES
None
- django_socio_grpc.protobuf.proto_classes.TYPING_TO_PROTO_TYPES
None
- class django_socio_grpc.protobuf.proto_classes.ProtoFieldConvertible
Bases:
abc.ABCMixin to convert a class to a ProtoField
- abstract to_proto_field(proto_field_cls: type[django_socio_grpc.protobuf.proto_classes.ProtoField], **kwargs) django_socio_grpc.protobuf.proto_classes.ProtoField