django_socio_grpc.mixins

Module Contents

Classes

CreateModelMixin

ListModelMixin

StreamModelMixin

RetrieveModelMixin

UpdateModelMixin

PartialUpdateModelMixin

DestroyModelMixin

AsyncCreateModelMixin

AsyncListModelMixin

AsyncStreamModelMixin

AsyncRetrieveModelMixin

AsyncUpdateModelMixin

AsyncPartialUpdateModelMixin

AsyncDestroyModelMixin

Functions

get_default_grpc_methods

return the default grpc methods generated for a django model.

get_default_grpc_messages

return the default protobuff message we want to generate

API

class django_socio_grpc.mixins.CreateModelMixin

Bases: django_socio_grpc.grpc_actions.actions.GRPCActionMixin

Create(request, context)

Create a model instance.

The request should be a proto message of serializer.Meta.proto_class. If an object is created this returns a proto message of serializer.Meta.proto_class.

perform_create(serializer)

Save a new object instance.

static get_default_method(model_name)
static get_default_message(model_name, fields='__all__')
class django_socio_grpc.mixins.ListModelMixin

Bases: django_socio_grpc.grpc_actions.actions.GRPCActionMixin

List(request, context)

List a queryset. This sends a message array of serializer.Meta.proto_class to the client.

.. note::

This is a server streaming RPC.
static get_default_method(model_name)
static get_default_message(model_name, fields=None, pagination=None, response_field_name=DEFAULT_LIST_FIELD_NAME)
class django_socio_grpc.mixins.StreamModelMixin

Bases: django_socio_grpc.grpc_actions.actions.GRPCActionMixin

Stream(request, context)

List a queryset. This sends a sequence of messages of serializer.Meta.proto_class to the client.

.. note::

This is a server streaming RPC.
static get_default_method(model_name)
static get_default_message(model_name, fields=None)
class django_socio_grpc.mixins.RetrieveModelMixin

Bases: django_socio_grpc.grpc_actions.actions.GRPCActionMixin

Retrieve(request, context)

Retrieve a model instance.

The request have to include a field corresponding to lookup_request_field. If an object can be retrieved this returns a proto message of serializer.Meta.proto_class.

static get_default_method(model_name)
static get_default_message(model_name, fields='__pk__')
class django_socio_grpc.mixins.UpdateModelMixin

Bases: django_socio_grpc.grpc_actions.actions.GRPCActionMixin

Update(request, context)

Update a model instance.

The request should be a proto message of serializer.Meta.proto_class. If an object is updated this returns a proto message of serializer.Meta.proto_class.

perform_update(serializer)

Save an existing object instance.

static get_default_method(model_name)
static get_default_message(model_name, fields='__all__')
class django_socio_grpc.mixins.PartialUpdateModelMixin

Bases: django_socio_grpc.grpc_actions.actions.GRPCActionMixin

PartialUpdate(request, context)

Partial update a model instance.

Performs a partial update on the given PARTIAL_UPDATE_FIELD_NAME(_partial_update_fields).

perform_partial_update(serializer)

Save an existing object instance.

static get_default_method(model_name)
static get_default_message(model_name, fields='__all__')
class django_socio_grpc.mixins.DestroyModelMixin

Bases: django_socio_grpc.grpc_actions.actions.GRPCActionMixin

Destroy(request, context)

Destroy a model instance.

The request have to include a field corresponding to lookup_request_field. If an object is deleted this returns a proto message of google.protobuf.empty_pb2.Empty.

perform_destroy(instance)

Delete an object instance.

static get_default_method(model_name)
static get_default_message(model_name, fields='__pk__')
class django_socio_grpc.mixins.AsyncCreateModelMixin

Bases: django_socio_grpc.mixins.CreateModelMixin

async Create(request, context)

Create a model instance.

The request should be a proto message of serializer.Meta.proto_class. If an object is created this returns a proto message of serializer.Meta.proto_class.

async aperform_create(serializer)

Save a new object instance.

class django_socio_grpc.mixins.AsyncListModelMixin

Bases: django_socio_grpc.mixins.ListModelMixin

async List(request, context)

List a queryset. This sends a message array of serializer.Meta.proto_class to the client.

.. note::

This is a server streaming RPC.
class django_socio_grpc.mixins.AsyncStreamModelMixin

Bases: django_socio_grpc.mixins.StreamModelMixin

async _get_list_data()
async Stream(request, context)

List a queryset. This sends a sequence of messages of serializer.Meta.proto_class to the client.

.. note::

This is a server streaming RPC.
class django_socio_grpc.mixins.AsyncRetrieveModelMixin

Bases: django_socio_grpc.mixins.RetrieveModelMixin

async Retrieve(request, context)

Retrieve a model instance.

The request have to include a field corresponding to lookup_request_field. If an object can be retrieved this returns a proto message of serializer.Meta.proto_class.

class django_socio_grpc.mixins.AsyncUpdateModelMixin

Bases: django_socio_grpc.mixins.UpdateModelMixin

async Update(request, context)

Update a model instance.

The request should be a proto message of serializer.Meta.proto_class. If an object is updated this returns a proto message of serializer.Meta.proto_class.

async aperform_update(serializer)

Save an existing object instance.

class django_socio_grpc.mixins.AsyncPartialUpdateModelMixin

Bases: django_socio_grpc.mixins.PartialUpdateModelMixin

async PartialUpdate(request, context)

Partial update a model instance.

Performs a partial update on the given PARTIAL_UPDATE_FIELD_NAME(_partial_update_fields).

async aperform_partial_update(serializer)

Save an existing object instance.

class django_socio_grpc.mixins.AsyncDestroyModelMixin

Bases: django_socio_grpc.mixins.DestroyModelMixin

async Destroy(request, context)

Destroy a model instance.

The request have to include a field corresponding to lookup_request_field. If an object is deleted this returns a proto message of google.protobuf.empty_pb2.Empty.

async aperform_destroy(instance)

Delete an object instance.

django_socio_grpc.mixins.get_default_grpc_methods(model_name)

return the default grpc methods generated for a django model.

django_socio_grpc.mixins.get_default_grpc_messages(model_name)

return the default protobuff message we want to generate