func (s *Server) EntityUpdate(ctx context.Context, r *pb.EntityRequest) (*pb.Empty, error) {
	if err := s.mutablePrequisitesMet(ctx, types.Capability_MODIFY_ENTITY_META); err != nil {
		return &pb.Empty{}, err
	}
	de := r.GetData()
	switch err := s.UpdateEntityMeta(de.GetID(), de.GetMeta()); err {
	case db.ErrUnknownEntity:
		s.log.Warn("Entity does not exist!",
			"method", "EntityUpdate",
			"entity", de.GetID(),
			"service", getServiceName(ctx),
			"client", getClientName(ctx),
		)
		return &pb.Empty{}, ErrDoesNotExist
	case nil:
		s.log.Info("Entity Updated",
			"entity", de.GetID(),
			"authority", getTokenClaims(ctx).EntityID,
			"service", getServiceName(ctx),
			"client", getClientName(ctx),
			"error", err,
		)
		return &pb.Empty{}, nil
	default:
		s.log.Warn("Error Updating Entity",
			"entity", de.GetID(),
			"authority", getTokenClaims(ctx).EntityID,
			"service", getServiceName(ctx),
			"client", getClientName(ctx),
			"error", err,
		)
		return &pb.Empty{}, ErrInternal
	}
}
EntityUpdate provides a change to specific entity metadata that is
in the typed data fields.  This method does not update keys,
groups, untyped metadata, or capabilities.  To call this method you
must be in possession of a token with MODIFY_ENTITY_META
capabilities.
package rpc2
import (
	"context"
	"github.com/netauth/netauth/internal/db"
	"github.com/netauth/netauth/internal/tree"
	types "github.com/netauth/protocol"
	pb "github.com/netauth/protocol/v2"
)
func (s *Server) EntityCreate(ctx context.Context, r *pb.EntityRequest) (*pb.Empty, error) {
	if err := s.mutablePrequisitesMet(ctx, types.Capability_CREATE_ENTITY); err != nil {
		return &pb.Empty{}, err
	}
	e := r.GetEntity()
	switch err := s.CreateEntity(e.GetID(), e.GetNumber(), e.GetSecret()); err {
	case tree.ErrDuplicateEntityID, tree.ErrDuplicateNumber:
		s.log.Warn("Attempt to create duplicate entity",
			"entity", e.GetID(),
			"authority", getTokenClaims(ctx).EntityID,
			"service", getServiceName(ctx),
			"client", getClientName(ctx),
			"error", err,
		)
		return &pb.Empty{}, ErrExists
	case nil:
		s.log.Info("Entity Created",
			"entity", e.GetID(),
			"authority", getTokenClaims(ctx).EntityID,
			"service", getServiceName(ctx),
			"client", getClientName(ctx),
			"error", err,
		)
		return &pb.Empty{}, nil
	default:
		s.log.Warn("Error Creating Entity",
			"entity", e.GetID(),
			"authority", getTokenClaims(ctx).EntityID,
			"service", getServiceName(ctx),
			"client", getClientName(ctx),
			"error", err,
		)
		return &pb.Empty{}, ErrInternal
	}
}