django_socio_grpc.protobuf.generation_plugin
Module Contents
Classes
The base class to create generation plugins. |
|
Util class to inherit for adding a field in a request proto message. By inerhit it and fill field_name, field_cardinality and field_type it will create a plugin that add a field without having to override any method. |
|
Plugin to add the _filters field in the request ProtoMessage. See https://django-socio-grpc.readthedocs.io/en/stable/features/filters.html#djangofilterbackend |
|
Plugin to add the _pagination field in the request ProtoMessage. See https://django-socio-grpc.readthedocs.io/en/stable/features/pagination.html |
|
Plugin allowing to encapsulate a message into an other message and put it as a repeated field to return multiple instance. Do not use directly, use one of it’s subclass RequestAsListGenerationPlugin, ResponseAsListGenerationPlugin or RequestAndResponseAsListGenerationPlugin |
|
Transform a request ProtoMessage in a list ProtoMessage |
|
Transform a response ProtoMessage in a list ProtoMessage |
|
Transform both request and response ProtoMessage in list ProtoMessage |
|
Transform both request and response ProtoMessage in list ProtoMessage |
|
Data
API
- django_socio_grpc.protobuf.generation_plugin.logger
‘getLogger(…)’
- class django_socio_grpc.protobuf.generation_plugin.BaseGenerationPlugin
The base class to create generation plugins.
- check_condition(service: type[django_socio_grpc.services.Service], request_message: django_socio_grpc.protobuf.proto_classes.ProtoMessage | str, response_message: django_socio_grpc.protobuf.proto_classes.ProtoMessage | str, message_name_constructor: django_socio_grpc.protobuf.message_name_constructor.MessageNameConstructor) bool
Method that allow to return without modifying the proto if some conditions are not met
- transform_request_message(service: type[django_socio_grpc.services.Service], proto_message: django_socio_grpc.protobuf.proto_classes.ProtoMessage | str, message_name_constructor: django_socio_grpc.protobuf.message_name_constructor.MessageNameConstructor) django_socio_grpc.protobuf.proto_classes.ProtoMessage
The actual method that transform the request ProtoMessage
- transform_response_message(service: type[django_socio_grpc.services.Service], proto_message: django_socio_grpc.protobuf.proto_classes.ProtoMessage | str, message_name_constructor: django_socio_grpc.protobuf.message_name_constructor.MessageNameConstructor) django_socio_grpc.protobuf.proto_classes.ProtoMessage
The actual method that transform the response ProtoMessage
- run_validation_and_transform(service: type[django_socio_grpc.services.Service], request_message: django_socio_grpc.protobuf.proto_classes.ProtoMessage | str, response_message: django_socio_grpc.protobuf.proto_classes.ProtoMessage | str, message_name_constructor: django_socio_grpc.protobuf.message_name_constructor.MessageNameConstructor) tuple[django_socio_grpc.protobuf.proto_classes.ProtoMessage, django_socio_grpc.protobuf.proto_classes.ProtoMessage]
The main orchestrator method of the plugin. This is the first entrypoint. It check the confition setted by check_condition method and then call transform_request_message and transform_response_message
- class django_socio_grpc.protobuf.generation_plugin.BaseAddFieldRequestGenerationPlugin(*args, **kwargs)
Bases:
django_socio_grpc.protobuf.generation_plugin.BaseGenerationPluginUtil class to inherit for adding a field in a request proto message. By inerhit it and fill field_name, field_cardinality and field_type it will create a plugin that add a field without having to override any method.
Initialization
- field_type: str | django_socio_grpc.protobuf.proto_classes.ProtoMessage
None
- field_cardinality: django_socio_grpc.protobuf.proto_classes.FieldCardinality
None
- transform_request_message(service: type[django_socio_grpc.services.Service], proto_message: django_socio_grpc.protobuf.proto_classes.ProtoMessage | str, message_name_constructor: django_socio_grpc.protobuf.message_name_constructor.MessageNameConstructor)
- class django_socio_grpc.protobuf.generation_plugin.FilterGenerationPlugin(display_warning_message=True)
Bases:
django_socio_grpc.protobuf.generation_plugin.BaseAddFieldRequestGenerationPluginPlugin to add the _filters field in the request ProtoMessage. See https://django-socio-grpc.readthedocs.io/en/stable/features/filters.html#djangofilterbackend
Initialization
- field_type: str | django_socio_grpc.protobuf.proto_classes.ProtoMessage
‘google.protobuf.Struct’
- field_cardinality: django_socio_grpc.protobuf.proto_classes.FieldCardinality
None
- check_condition(service: type[django_socio_grpc.services.Service], request_message: django_socio_grpc.protobuf.proto_classes.ProtoMessage | str, response_message: django_socio_grpc.protobuf.proto_classes.ProtoMessage | str, message_name_constructor: django_socio_grpc.protobuf.message_name_constructor.MessageNameConstructor) bool
- class django_socio_grpc.protobuf.generation_plugin.PaginationGenerationPlugin(display_warning_message=True)
Bases:
django_socio_grpc.protobuf.generation_plugin.BaseAddFieldRequestGenerationPluginPlugin to add the _pagination field in the request ProtoMessage. See https://django-socio-grpc.readthedocs.io/en/stable/features/pagination.html
Initialization
- field_type: str | django_socio_grpc.protobuf.proto_classes.ProtoMessage
‘google.protobuf.Struct’
- field_cardinality: django_socio_grpc.protobuf.proto_classes.FieldCardinality
None
- check_condition(service: type[django_socio_grpc.services.Service], request_message: django_socio_grpc.protobuf.proto_classes.ProtoMessage | str, response_message: django_socio_grpc.protobuf.proto_classes.ProtoMessage | str, message_name_constructor: django_socio_grpc.protobuf.message_name_constructor.MessageNameConstructor) bool
- class django_socio_grpc.protobuf.generation_plugin.AsListGenerationPlugin
Bases:
django_socio_grpc.protobuf.generation_plugin.BaseGenerationPluginPlugin allowing to encapsulate a message into an other message and put it as a repeated field to return multiple instance. Do not use directly, use one of it’s subclass RequestAsListGenerationPlugin, ResponseAsListGenerationPlugin or RequestAndResponseAsListGenerationPlugin
- transform_message_to_list(service: type[django_socio_grpc.services.Service], proto_message: django_socio_grpc.protobuf.proto_classes.ProtoMessage | str, list_name: str) django_socio_grpc.protobuf.proto_classes.ProtoMessage
- class django_socio_grpc.protobuf.generation_plugin.RequestAsListGenerationPlugin
Bases:
django_socio_grpc.protobuf.generation_plugin.AsListGenerationPluginTransform a request ProtoMessage in a list ProtoMessage
- transform_request_message(service: type[django_socio_grpc.services.Service], proto_message: django_socio_grpc.protobuf.proto_classes.ProtoMessage | str, message_name_constructor: django_socio_grpc.protobuf.message_name_constructor.MessageNameConstructor) django_socio_grpc.protobuf.proto_classes.ProtoMessage
- class django_socio_grpc.protobuf.generation_plugin.ResponseAsListGenerationPlugin
Bases:
django_socio_grpc.protobuf.generation_plugin.AsListGenerationPluginTransform a response ProtoMessage in a list ProtoMessage
- transform_response_message(service: type[django_socio_grpc.services.Service], proto_message: django_socio_grpc.protobuf.proto_classes.ProtoMessage | str, message_name_constructor: django_socio_grpc.protobuf.message_name_constructor.MessageNameConstructor) django_socio_grpc.protobuf.proto_classes.ProtoMessage
- class django_socio_grpc.protobuf.generation_plugin.RequestAndResponseAsListGenerationPlugin
Bases:
django_socio_grpc.protobuf.generation_plugin.RequestAsListGenerationPlugin,django_socio_grpc.protobuf.generation_plugin.ResponseAsListGenerationPluginTransform both request and response ProtoMessage in list ProtoMessage
- class django_socio_grpc.protobuf.generation_plugin.ListGenerationPlugin
Bases:
django_socio_grpc.protobuf.generation_plugin.RequestAsListGenerationPlugin,django_socio_grpc.protobuf.generation_plugin.ResponseAsListGenerationPluginTransform both request and response ProtoMessage in list ProtoMessage
- transform_response_message(service: type[django_socio_grpc.services.Service], proto_message: django_socio_grpc.protobuf.proto_classes.ProtoMessage | str, message_name_constructor: django_socio_grpc.protobuf.message_name_constructor.MessageNameConstructor) django_socio_grpc.protobuf.proto_classes.ProtoMessage
- transform_request_message(service: type[django_socio_grpc.services.Service], proto_message: django_socio_grpc.protobuf.proto_classes.ProtoMessage | str, message_name_constructor: django_socio_grpc.protobuf.message_name_constructor.MessageNameConstructor) django_socio_grpc.protobuf.proto_classes.ProtoMessage
- class django_socio_grpc.protobuf.generation_plugin.BaseEnumGenerationPlugin
Bases:
django_socio_grpc.protobuf.generation_plugin.BaseGenerationPlugin- transform_request_message(service: type[django_socio_grpc.services.Service], proto_message: django_socio_grpc.protobuf.proto_classes.ProtoMessage | str, message_name_constructor: django_socio_grpc.protobuf.message_name_constructor.MessageNameConstructor)
- handle_serializer(proto_message: django_socio_grpc.protobuf.proto_classes.ProtoMessage)
Handle enum generation for a ProtoMessage that has a serializer.
An enum can be generated either from:
An Annotated Enum (e.g. Annotated[models.CharField, MyTextChoices])
A ChoiceField with string choices (e.g. [“CHOICE_1”, “CHOICE_2”]) if non_annotated_generation is True
- handle_field_dict(proto_message: django_socio_grpc.protobuf.proto_classes.ProtoMessage)
- transform_response_message(service: type[django_socio_grpc.services.Service], proto_message: django_socio_grpc.protobuf.proto_classes.ProtoMessage | str, message_name_constructor: django_socio_grpc.protobuf.message_name_constructor.MessageNameConstructor) django_socio_grpc.protobuf.proto_classes.ProtoMessage
- abstract set_field_type(field: django_socio_grpc.protobuf.proto_classes.ProtoField, enum: enum.Enum)
- build_enum_from_choice_field(field: rest_framework.serializers.ChoiceField)
- class django_socio_grpc.protobuf.generation_plugin.InMessageEnumGenerationPlugin
Bases:
django_socio_grpc.protobuf.generation_plugin.BaseEnumGenerationPlugin- set_field_type(field: django_socio_grpc.protobuf.proto_classes.ProtoField, enum: enum.Enum)
- class django_socio_grpc.protobuf.generation_plugin.InMessageWrappedEnumGenerationPlugin
Bases:
django_socio_grpc.protobuf.generation_plugin.BaseEnumGenerationPlugin- set_field_type(field: django_socio_grpc.protobuf.proto_classes.ProtoField, enum: enum.Enum)
- class django_socio_grpc.protobuf.generation_plugin.GlobalScopeEnumGenerationPlugin
Bases:
django_socio_grpc.protobuf.generation_plugin.BaseEnumGenerationPlugin- set_field_type(field: django_socio_grpc.protobuf.proto_classes.ProtoField, enum: enum.Enum)
- class django_socio_grpc.protobuf.generation_plugin.GlobalScopeWrappedEnumGenerationPlugin
Bases:
django_socio_grpc.protobuf.generation_plugin.BaseEnumGenerationPlugin- set_field_type(field: django_socio_grpc.protobuf.proto_classes.ProtoField, enum: enum.Enum)