generated from Luis/nextjs-python-web-template
Added usage field to service
This commit is contained in:
@@ -24,6 +24,8 @@ from openapi_client.models.resolution import Resolution
|
||||
from openapi_client.models.role import Role
|
||||
from openapi_client.models.service import Service
|
||||
from openapi_client.models.service_create import ServiceCreate
|
||||
from openapi_client.models.service_usage import ServiceUsage
|
||||
from openapi_client.models.service_usage_create import ServiceUsageCreate
|
||||
from openapi_client.models.status import Status
|
||||
from openapi_client.models.validation_error import ValidationError
|
||||
from openapi_client.models.validation_error_loc_inner import ValidationErrorLocInner
|
||||
|
||||
@@ -19,7 +19,7 @@ import json
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict
|
||||
from pydantic import BaseModel, Field, StrictInt, StrictStr
|
||||
from pydantic import BaseModel, Field, StrictStr
|
||||
|
||||
class Resolution(BaseModel):
|
||||
"""
|
||||
@@ -30,8 +30,7 @@ class Resolution(BaseModel):
|
||||
resolved_did: StrictStr = Field(...)
|
||||
other: Dict[str, Any] = Field(...)
|
||||
timestamp: datetime = Field(...)
|
||||
id: StrictInt = Field(...)
|
||||
__properties = ["requester_name", "requester_did", "resolved_did", "other", "timestamp", "id"]
|
||||
__properties = ["requester_name", "requester_did", "resolved_did", "other", "timestamp"]
|
||||
|
||||
class Config:
|
||||
"""Pydantic configuration"""
|
||||
@@ -73,8 +72,7 @@ class Resolution(BaseModel):
|
||||
"requester_did": obj.get("requester_did"),
|
||||
"resolved_did": obj.get("resolved_did"),
|
||||
"other": obj.get("other"),
|
||||
"timestamp": obj.get("timestamp"),
|
||||
"id": obj.get("id")
|
||||
"timestamp": obj.get("timestamp")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -18,9 +18,10 @@ import re # noqa: F401
|
||||
import json
|
||||
|
||||
|
||||
from typing import Any, Dict
|
||||
from pydantic import BaseModel, Field, StrictStr
|
||||
from typing import Any, Dict, List
|
||||
from pydantic import BaseModel, Field, StrictStr, conlist
|
||||
from openapi_client.models.entity import Entity
|
||||
from openapi_client.models.service_usage import ServiceUsage
|
||||
|
||||
class Service(BaseModel):
|
||||
"""
|
||||
@@ -32,9 +33,9 @@ class Service(BaseModel):
|
||||
endpoint_url: StrictStr = Field(...)
|
||||
status: StrictStr = Field(...)
|
||||
other: Dict[str, Any] = Field(...)
|
||||
entity_did: StrictStr = Field(...)
|
||||
entity: Entity = Field(...)
|
||||
__properties = ["uuid", "service_name", "service_type", "endpoint_url", "status", "other", "entity_did", "entity"]
|
||||
usage: conlist(ServiceUsage) = Field(...)
|
||||
__properties = ["uuid", "service_name", "service_type", "endpoint_url", "status", "other", "entity", "usage"]
|
||||
|
||||
class Config:
|
||||
"""Pydantic configuration"""
|
||||
@@ -63,6 +64,13 @@ class Service(BaseModel):
|
||||
# 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)
|
||||
_items = []
|
||||
if self.usage:
|
||||
for _item in self.usage:
|
||||
if _item:
|
||||
_items.append(_item.to_dict())
|
||||
_dict['usage'] = _items
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
@@ -81,8 +89,8 @@ class Service(BaseModel):
|
||||
"endpoint_url": obj.get("endpoint_url"),
|
||||
"status": obj.get("status"),
|
||||
"other": obj.get("other"),
|
||||
"entity_did": obj.get("entity_did"),
|
||||
"entity": Entity.from_dict(obj.get("entity")) if obj.get("entity") is not None else None
|
||||
"entity": Entity.from_dict(obj.get("entity")) if obj.get("entity") 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
|
||||
|
||||
|
||||
@@ -18,8 +18,9 @@ import re # noqa: F401
|
||||
import json
|
||||
|
||||
|
||||
from typing import Any, Dict
|
||||
from pydantic import BaseModel, Field, StrictStr
|
||||
from typing import Any, Dict, List
|
||||
from pydantic import BaseModel, Field, StrictStr, conlist
|
||||
from openapi_client.models.service_usage_create import ServiceUsageCreate
|
||||
|
||||
class ServiceCreate(BaseModel):
|
||||
"""
|
||||
@@ -32,7 +33,8 @@ class ServiceCreate(BaseModel):
|
||||
status: StrictStr = Field(...)
|
||||
other: Dict[str, Any] = Field(...)
|
||||
entity_did: StrictStr = Field(...)
|
||||
__properties = ["uuid", "service_name", "service_type", "endpoint_url", "status", "other", "entity_did"]
|
||||
usage: conlist(ServiceUsageCreate) = Field(...)
|
||||
__properties = ["uuid", "service_name", "service_type", "endpoint_url", "status", "other", "entity_did", "usage"]
|
||||
|
||||
class Config:
|
||||
"""Pydantic configuration"""
|
||||
@@ -58,6 +60,13 @@ class ServiceCreate(BaseModel):
|
||||
exclude={
|
||||
},
|
||||
exclude_none=True)
|
||||
# override the default output from pydantic by calling `to_dict()` of each item in usage (list)
|
||||
_items = []
|
||||
if self.usage:
|
||||
for _item in self.usage:
|
||||
if _item:
|
||||
_items.append(_item.to_dict())
|
||||
_dict['usage'] = _items
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
@@ -76,7 +85,8 @@ class ServiceCreate(BaseModel):
|
||||
"endpoint_url": obj.get("endpoint_url"),
|
||||
"status": obj.get("status"),
|
||||
"other": obj.get("other"),
|
||||
"entity_did": obj.get("entity_did")
|
||||
"entity_did": obj.get("entity_did"),
|
||||
"usage": [ServiceUsageCreate.from_dict(_item) for _item in obj.get("usage")] if obj.get("usage") is not None else None
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
73
pkgs/clan-cli/tests/openapi_client/models/service_usage.py
Normal file
73
pkgs/clan-cli/tests/openapi_client/models/service_usage.py
Normal file
@@ -0,0 +1,73 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
FastAPI
|
||||
|
||||
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
||||
|
||||
The version of the OpenAPI document: 0.1.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
|
||||
|
||||
from pydantic import BaseModel, Field, StrictInt, StrictStr
|
||||
|
||||
class ServiceUsage(BaseModel):
|
||||
"""
|
||||
ServiceUsage
|
||||
"""
|
||||
times_consumed: StrictInt = Field(...)
|
||||
consumer_entity_did: StrictStr = Field(...)
|
||||
__properties = ["times_consumed", "consumer_entity_did"]
|
||||
|
||||
class Config:
|
||||
"""Pydantic configuration"""
|
||||
allow_population_by_field_name = True
|
||||
validate_assignment = True
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.dict(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> ServiceUsage:
|
||||
"""Create an instance of ServiceUsage from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self):
|
||||
"""Returns the dictionary representation of the model using alias"""
|
||||
_dict = self.dict(by_alias=True,
|
||||
exclude={
|
||||
},
|
||||
exclude_none=True)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: dict) -> ServiceUsage:
|
||||
"""Create an instance of ServiceUsage from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return ServiceUsage.parse_obj(obj)
|
||||
|
||||
_obj = ServiceUsage.parse_obj({
|
||||
"times_consumed": obj.get("times_consumed"),
|
||||
"consumer_entity_did": obj.get("consumer_entity_did")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
FastAPI
|
||||
|
||||
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
||||
|
||||
The version of the OpenAPI document: 0.1.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
|
||||
|
||||
from pydantic import BaseModel, Field, StrictInt, StrictStr
|
||||
|
||||
class ServiceUsageCreate(BaseModel):
|
||||
"""
|
||||
ServiceUsageCreate
|
||||
"""
|
||||
times_consumed: StrictInt = Field(...)
|
||||
consumer_entity_did: StrictStr = Field(...)
|
||||
__properties = ["times_consumed", "consumer_entity_did"]
|
||||
|
||||
class Config:
|
||||
"""Pydantic configuration"""
|
||||
allow_population_by_field_name = True
|
||||
validate_assignment = True
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.dict(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> ServiceUsageCreate:
|
||||
"""Create an instance of ServiceUsageCreate from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self):
|
||||
"""Returns the dictionary representation of the model using alias"""
|
||||
_dict = self.dict(by_alias=True,
|
||||
exclude={
|
||||
},
|
||||
exclude_none=True)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: dict) -> ServiceUsageCreate:
|
||||
"""Create an instance of ServiceUsageCreate from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return ServiceUsageCreate.parse_obj(obj)
|
||||
|
||||
_obj = ServiceUsageCreate.parse_obj({
|
||||
"times_consumed": obj.get("times_consumed"),
|
||||
"consumer_entity_did": obj.get("consumer_entity_did")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
Reference in New Issue
Block a user