generated from Luis/nextjs-python-web-template
Added usage field to service #53
@@ -100,15 +100,14 @@ class ServiceBase(BaseModel):
|
|||||||
other: dict = Field(
|
other: dict = Field(
|
||||||
..., example={"action": ["register", "deregister", "delete", "create"]}
|
..., example={"action": ["register", "deregister", "delete", "create"]}
|
||||||
)
|
)
|
||||||
|
entity_did: str = Field(..., example="did:sov:test:120")
|
||||||
|
|
||||||
|
|
||||||
class ServiceCreate(ServiceBase):
|
class ServiceCreate(ServiceBase):
|
||||||
entity_did: str = Field(..., example="did:sov:test:120")
|
|
||||||
usage: List[ServiceUsageCreate]
|
usage: List[ServiceUsageCreate]
|
||||||
|
|
||||||
|
|
||||||
class Service(ServiceBase):
|
class Service(ServiceBase):
|
||||||
entity: Entity
|
|
||||||
usage: List[ServiceUsage]
|
usage: List[ServiceUsage]
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
@@ -116,7 +115,6 @@ class Service(ServiceBase):
|
|||||||
|
|
||||||
|
|
||||||
class ServicesByName(BaseModel):
|
class ServicesByName(BaseModel):
|
||||||
entity: Entity
|
|
||||||
services: List[Service]
|
services: List[Service]
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
| **endpoint_url** | **str** | |
|
| **endpoint_url** | **str** | |
|
||||||
| **status** | **str** | |
|
| **status** | **str** | |
|
||||||
| **other** | **object** | |
|
| **other** | **object** | |
|
||||||
| **entity** | [**Entity**](Entity.md) | |
|
| **entity_did** | **str** | |
|
||||||
| **usage** | [**List[ServiceUsage]**](ServiceUsage.md) | |
|
| **usage** | [**List[ServiceUsage]**](ServiceUsage.md) | |
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import json
|
|||||||
|
|
||||||
from typing import Any, Dict, List
|
from typing import Any, Dict, List
|
||||||
from pydantic import BaseModel, Field, StrictStr, conlist
|
from pydantic import BaseModel, Field, StrictStr, conlist
|
||||||
from openapi_client.models.entity import Entity
|
|
||||||
from openapi_client.models.service_usage import ServiceUsage
|
from openapi_client.models.service_usage import ServiceUsage
|
||||||
|
|
||||||
class Service(BaseModel):
|
class Service(BaseModel):
|
||||||
@@ -33,9 +32,9 @@ class Service(BaseModel):
|
|||||||
endpoint_url: StrictStr = Field(...)
|
endpoint_url: StrictStr = Field(...)
|
||||||
status: StrictStr = Field(...)
|
status: StrictStr = Field(...)
|
||||||
other: Dict[str, Any] = Field(...)
|
other: Dict[str, Any] = Field(...)
|
||||||
entity: Entity = Field(...)
|
entity_did: StrictStr = Field(...)
|
||||||
usage: conlist(ServiceUsage) = Field(...)
|
usage: conlist(ServiceUsage) = Field(...)
|
||||||
__properties = ["uuid", "service_name", "service_type", "endpoint_url", "status", "other", "entity", "usage"]
|
__properties = ["uuid", "service_name", "service_type", "endpoint_url", "status", "other", "entity_did", "usage"]
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
"""Pydantic configuration"""
|
"""Pydantic configuration"""
|
||||||
@@ -61,9 +60,6 @@ class Service(BaseModel):
|
|||||||
exclude={
|
exclude={
|
||||||
},
|
},
|
||||||
exclude_none=True)
|
exclude_none=True)
|
||||||
# override the default output from pydantic by calling `to_dict()` of entity
|
|
||||||
if self.entity:
|
|
||||||
_dict['entity'] = self.entity.to_dict()
|
|
||||||
# override the default output from pydantic by calling `to_dict()` of each item in usage (list)
|
# override the default output from pydantic by calling `to_dict()` of each item in usage (list)
|
||||||
_items = []
|
_items = []
|
||||||
if self.usage:
|
if self.usage:
|
||||||
@@ -89,7 +85,7 @@ class Service(BaseModel):
|
|||||||
"endpoint_url": obj.get("endpoint_url"),
|
"endpoint_url": obj.get("endpoint_url"),
|
||||||
"status": obj.get("status"),
|
"status": obj.get("status"),
|
||||||
"other": obj.get("other"),
|
"other": obj.get("other"),
|
||||||
"entity": Entity.from_dict(obj.get("entity")) if obj.get("entity") is not None else None,
|
"entity_did": obj.get("entity_did"),
|
||||||
"usage": [ServiceUsage.from_dict(_item) for _item in obj.get("usage")] if obj.get("usage") is not None else None
|
"usage": [ServiceUsage.from_dict(_item) for _item in obj.get("usage")] if obj.get("usage") is not None else None
|
||||||
})
|
})
|
||||||
return _obj
|
return _obj
|
||||||
|
|||||||
Reference in New Issue
Block a user