* python version updated from 3.9 into 3.12 * x2text-service updated with uv and python version 3.12 * x2text-service docker file updated * Unstract packages updated with uv * Runner updated with uv * Promptservice updated with uv * Platform service updated with uv * backend service updated with uv * root pyproject.toml file updated * sdk version updated in services * unstract package modules updated based on sdk version: * docker file update * pdm lock workflow modified to support uv * Docs updated based on uv support * lock automation updated * snowflake module version updated into 3.14.0 * tox updated to support UV * tox updated to support UV * tox updated with pytest * tox updated with pytest-md-report * tox updated with module requirements * python migration from 3.9 to 3.12 * tox updated with module requirements * runner updated * Commit uv.lock changes * runner updated * Commit uv.lock changes * pytest.ini added * x2text-service docker file updated * pytest.ini removed * environment updated to test * docformatter commented on pre-commit * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * some pre-commit issues ignored * some pre-commit issues ignored * some pre-commit issues ignored * some pre-commit issues ignored * some pre-commit issues ignored * pre-commit updates * un used import removed from platfrom service controller * tox issue fixed * tox issue fixed * docker files updated * backend dockerfile updated * open installation issue fixed * Tools docker file updated with base python version 3.12 * python version updated into min 3.12 in pyproject.toml * linting issue fixed * uv version upgraded into 0.6.14 * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * migrations excluded from ruff * added PoethePoet task runner * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * feat: Added poe tasks for services (#1248) * Added poe tasks for services * reverted FE change made by mistake * updated tool-sidecar to uv and python to 3.12.9 * minor updates in pyproject descreption * feat: platform-service logging improvements (#1255) feat: Used flask util from core to improve logging in platform-service, added core as a dependency to platform-service: * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix: Platform-service build issue and numpy issue with Python 3.12 (#1258) * fix: Platform-service build and numpy issue with Py 3.12 * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix: Removed backend dockerfile install statements for numpy --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> * minor: Handled scenario when cost is not calculated due to no usage * minor: Corrected content shown for workflow input * fix: Minor fixes, used gthread for prompt-service, runner * Commit uv.lock changes * Removed unused line in tool dockerfile --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Chandrasekharan M <chandrasekharan@zipstack.com> Co-authored-by: Chandrasekharan M <117059509+chandrasekharan-zipstack@users.noreply.github.com> Co-authored-by: ali-zipstack <muhammad.ali@zipstack.com>
122 lines
3.8 KiB
Python
122 lines
3.8 KiB
Python
import re
|
|
|
|
from rest_framework import serializers
|
|
|
|
from account_v2.models import Organization, User
|
|
|
|
|
|
class OrganizationSignupSerializer(serializers.Serializer):
|
|
name = serializers.CharField(required=True, max_length=150)
|
|
display_name = serializers.CharField(required=True, max_length=150)
|
|
organization_id = serializers.CharField(required=True, max_length=30)
|
|
|
|
def validate_organization_id(self, value): # type: ignore
|
|
if not re.match(r"^[a-z0-9_-]+$", value):
|
|
raise serializers.ValidationError(
|
|
"organization_code should only contain "
|
|
"alphanumeric characters,_ and -."
|
|
)
|
|
return value
|
|
|
|
|
|
class OrganizationCallbackSerializer(serializers.Serializer):
|
|
id = serializers.CharField(required=False)
|
|
|
|
|
|
class GetOrganizationsResponseSerializer(serializers.Serializer):
|
|
id = serializers.CharField()
|
|
display_name = serializers.CharField()
|
|
name = serializers.CharField()
|
|
metadata = serializers.JSONField(required=False, allow_null=True)
|
|
# Add more fields as needed
|
|
|
|
def to_representation(self, instance): # type: ignore
|
|
data = super().to_representation(instance)
|
|
# Modify the representation if needed
|
|
return data
|
|
|
|
|
|
class GetOrganizationMembersResponseSerializer(serializers.Serializer):
|
|
user_id = serializers.CharField()
|
|
email = serializers.CharField()
|
|
name = serializers.CharField()
|
|
picture = serializers.CharField()
|
|
# Add more fields as needed
|
|
|
|
def to_representation(self, instance): # type: ignore
|
|
data = super().to_representation(instance)
|
|
# Modify the representation if needed
|
|
return data
|
|
|
|
|
|
class OrganizationSerializer(serializers.Serializer):
|
|
name = serializers.CharField()
|
|
organization_id = serializers.CharField()
|
|
|
|
|
|
class SetOrganizationsResponseSerializer(serializers.Serializer):
|
|
id = serializers.CharField()
|
|
email = serializers.CharField()
|
|
name = serializers.CharField()
|
|
display_name = serializers.CharField()
|
|
family_name = serializers.CharField()
|
|
picture = serializers.CharField()
|
|
# Add more fields as needed
|
|
|
|
def to_representation(self, instance): # type: ignore
|
|
data = super().to_representation(instance)
|
|
# Modify the representation if needed
|
|
return data
|
|
|
|
|
|
class ModelTenantSerializer(serializers.ModelSerializer):
|
|
class Meta:
|
|
model = Organization
|
|
fields = fields = ("name", "created_on")
|
|
|
|
|
|
class UserSerializer(serializers.ModelSerializer):
|
|
class Meta:
|
|
model = User
|
|
fields = ("id", "username")
|
|
|
|
|
|
class OrganizationSignupResponseSerializer(serializers.Serializer):
|
|
name = serializers.CharField()
|
|
display_name = serializers.CharField()
|
|
organization_id = serializers.CharField()
|
|
created_at = serializers.CharField()
|
|
|
|
|
|
class LoginRequestSerializer(serializers.Serializer):
|
|
username = serializers.CharField(required=True)
|
|
password = serializers.CharField(required=True)
|
|
|
|
def validate_username(self, value: str | None) -> str:
|
|
"""Check that the username is not empty and has at least 3
|
|
characters.
|
|
"""
|
|
if not value or len(value) < 3:
|
|
raise serializers.ValidationError(
|
|
"Username must be at least 3 characters long."
|
|
)
|
|
return value
|
|
|
|
def validate_password(self, value: str | None) -> str:
|
|
"""Check that the password is not empty and has at least 3
|
|
characters.
|
|
"""
|
|
if not value or len(value) < 3:
|
|
raise serializers.ValidationError(
|
|
"Password must be at least 3 characters long."
|
|
)
|
|
return value
|
|
|
|
|
|
class UserSessionResponseSerializer(serializers.Serializer):
|
|
id = serializers.IntegerField()
|
|
user_id = serializers.CharField()
|
|
email = serializers.CharField()
|
|
organization_id = serializers.CharField()
|
|
role = serializers.CharField()
|