django_socio_grpc.protobuf.proto_classes

Module Contents

Classes

ProtoComment

This class is used to represent a comment in a proto file. It allows adding a comment in a serializer field help_text.

ProtoField

Represents a field in a proto message.

ProtoMessage

Represents a proto message with its fields and comments

RequestProtoMessage

ResponseProtoMessage

ProtoRpc

Represent a RPC method in a service

ProtoService

Represents a service in a proto file

Functions

get_proto_type

Return the proto type of a field, fields can either implement a proto_type attribute or be a subclass of a known field type.

Data

logger

EmptyMessage

StructMessage

FIELDS_TO_PROTO_TYPES

PRIMITIVE_TYPES

TYPING_TO_PROTO_TYPES

API

django_socio_grpc.protobuf.proto_classes.logger

None

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};
name: str

None

field_type: Union[str, ProtoMessage]

None

cardinality: django_socio_grpc.protobuf.typing.FieldCardinality

None

comments: Optional[List[str]]

None

index: int

0

property field_type_str: str
property field_line: str
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(field: rest_framework.serializers.Field) django_socio_grpc.protobuf.proto_classes.ProtoField
classmethod from_serializer(field: rest_framework.serializers.Serializer, to_message: 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 _from_serializer_method_field(field: rest_framework.serializers.SerializerMethodField) django_socio_grpc.protobuf.proto_classes.ProtoField
class django_socio_grpc.protobuf.proto_classes.ProtoMessage

Represents a proto message with its fields and comments

{comments}
message {name} {
    [{fields}]
}
base_name: str

None

fields: List[django_socio_grpc.protobuf.proto_classes.ProtoField]

None

comments: Optional[List[str]]

None

serializer: Optional[rest_framework.serializers.BaseSerializer]

None

imported_from: Optional[str]

None

suffixable: bool

True

prefixable: bool

True

prefix: str = <Multiline-String>
suffix: ClassVar[str] = <Multiline-String>
property name: str
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

append_name() str
classmethod create_name(base_name: str, suffixable: bool, prefixable: bool) str

This method only exist for stopping serializer recursion and using the correct ProtoMessage name

classmethod get_base_name_from_serializer(serializer: Type[rest_framework.serializers.BaseSerializer]) str
classmethod create(value: Optional[Union[Type[rest_framework.serializers.BaseSerializer], List[django_socio_grpc.protobuf.typing.FieldDict], str]], base_name: str, appendable_name: bool, prefix: str = '') Union[django_socio_grpc.protobuf.proto_classes.ProtoMessage, str]
classmethod from_field_dicts(fields: List[django_socio_grpc.protobuf.typing.FieldDict], base_name: str, appendable_name: bool = True, prefix: str = '') django_socio_grpc.protobuf.proto_classes.ProtoMessage
classmethod from_serializer(serializer: Type[rest_framework.serializers.BaseSerializer], name: Optional[str] = None) django_socio_grpc.protobuf.proto_classes.ProtoMessage
classmethod skip_field(field: Union[rest_framework.serializers.Field, rest_framework.serializers.BaseSerializer], pk_name: str) bool
classmethod as_list_message(base_message: django_socio_grpc.protobuf.proto_classes.ProtoMessage, base_name: Optional[str] = None, list_field_name: Optional[str] = None) django_socio_grpc.protobuf.proto_classes.ProtoMessage
__getitem__(key: str) django_socio_grpc.protobuf.proto_classes.ProtoField
__contains__(key: str) bool
class django_socio_grpc.protobuf.proto_classes.RequestProtoMessage

Bases: django_socio_grpc.protobuf.proto_classes.ProtoMessage

suffix: ClassVar

None

classmethod skip_field(field: Union[rest_framework.serializers.Field, rest_framework.serializers.BaseSerializer], pk_name: str) bool

Skip fields that are read_only on Request

class django_socio_grpc.protobuf.proto_classes.ResponseProtoMessage

Bases: django_socio_grpc.protobuf.proto_classes.ProtoMessage

suffix: ClassVar

None

classmethod skip_field(field: Union[rest_framework.serializers.Field, rest_framework.serializers.BaseSerializer], pk_name: str) bool

Skip fields that are write_only on Response

django_socio_grpc.protobuf.proto_classes.EmptyMessage

None

django_socio_grpc.protobuf.proto_classes.StructMessage

None

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}) {}
name: str

None

request: Union[django_socio_grpc.protobuf.proto_classes.ProtoMessage, str]

None

response: Union[django_socio_grpc.protobuf.proto_classes.ProtoMessage, str]

None

request_stream: bool

False

response_stream: bool

False

property request_name: str
property response_name: str
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}]
}
name: str

None

rpcs: List[django_socio_grpc.protobuf.proto_classes.ProtoRpc]

None

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: Union[django.db.models.Field, rest_framework.serializers.Field], default='string') str

Return the proto type of a field, fields can either implement a proto_type attribute 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