Stash changes

This commit is contained in:
2024-01-07 13:35:22 +01:00
parent aa664dfce1
commit bd30682092
38 changed files with 661 additions and 446 deletions

View File

@@ -1,7 +1,8 @@
from datetime import datetime
from enum import Enum
from typing import List
from pydantic import BaseModel
from pydantic import BaseModel, Field
class Status(Enum):
@@ -15,43 +16,23 @@ class Machine(BaseModel):
status: Status
#########################
# #
# Service #
# #
#########################
class ServiceBase(BaseModel):
uuid: str = "8e285c0c-4e40-430a-a477-26b3b81e30df"
service_name: str = "Carlos Printing"
service_type: str = "3D Printing"
endpoint_url: str = "http://127.0.0.1:8000"
status: str = "unknown"
other: dict = {"action": ["register", "deregister", "delete", "create"]}
class ServiceCreate(ServiceBase):
entity_did: str = "did:sov:test:1234"
class Service(ServiceCreate):
class Config:
orm_mode = True
#########################
# #
# Entity #
# #
#########################
class EntityBase(BaseModel):
did: str = "did:sov:test:1234"
name: str = "C1"
ip: str = "127.0.0.1"
visible: bool = True
other: dict = {
"network": "Carlos Home Network",
"roles": ["service repository", "service prosumer"],
}
did: str = Field(..., example="did:sov:test:1234")
name: str = Field(..., example="C1")
ip: str = Field(..., example="127.0.0.1")
visible: bool = Field(..., example=True)
other: dict = Field(
...,
example={
"network": "Carlos Home Network",
"roles": ["service repository", "service prosumer"],
},
)
class EntityCreate(EntityBase):
@@ -59,7 +40,42 @@ class EntityCreate(EntityBase):
class Entity(EntityCreate):
attached: bool
attached: bool = Field(...)
class Config:
orm_mode = True
#########################
# #
# Service #
# #
#########################
class ServiceBase(BaseModel):
uuid: str = Field(..., example="8e285c0c-4e40-430a-a477-26b3b81e30df")
service_name: str = Field(..., example="Carlos Printing")
service_type: str = Field(..., example="3D Printing")
endpoint_url: str = Field(..., example="http://127.0.0.1:8000")
status: str = Field(..., example="unknown")
other: dict = Field(
..., example={"action": ["register", "deregister", "delete", "create"]}
)
class ServiceCreate(ServiceBase):
entity_did: str = Field(..., example="did:sov:test:1234")
class Service(ServiceCreate):
entity: Entity
class Config:
orm_mode = True
class ServicesByName(BaseModel):
entity: Entity
services: List[Service]
class Config:
orm_mode = True
@@ -71,10 +87,10 @@ class Entity(EntityCreate):
# #
#########################
class ResolutionBase(BaseModel):
requester_name: str = "C1"
requester_did: str = "did:sov:test:1122"
resolved_did: str = "did:sov:test:1234"
other: dict = {"test": "test"}
requester_name: str = Field(..., example="C1")
requester_did: str = Field(..., example="did:sov:test:1122")
resolved_did: str = Field(..., example="did:sov:test:1234")
other: dict = Field(..., example={"test": "test"})
class ResolutionCreate(ResolutionBase):