1
0
Fork 0
forked from lthn/blockchain
blockchain/utils/sdk/client/python/lthn/models/info_model.py
Snider 88d4357628
New API Interface (#27)
This pull request introduces a comprehensive new API interface for the blockchain, leveraging OpenAPI v3 to facilitate direct consumption of chain data by GUI and web applications. This change significantly refines the project's build infrastructure, incorporating Conan for dependency management and CMake for configuration, alongside the integration of an OpenAPI Generator to produce SDKs for multiple languages. 

### Highlights

* **New API Interface**: Introduced a new API interface using OpenAPI v3 to enable GUI/WEB development to consume chain data without needing custom server applications.
* **Build System Enhancements**: Significant updates to the build system, including Makefile, CMake, and Conan configurations, to streamline the build process and support new functionalities.
* **Multi-language SDK Generation**: Integrated OpenAPI Generator to automatically create SDKs for various programming languages, including Go, Angular, and PHP, simplifying client-side integration.
2025-10-19 19:12:37 +01:00

185 lines
9.3 KiB
Python
Generated

# coding: utf-8
"""
Lethean Blockchain API
OpenAPI for Lethean Blockchain
The version of the OpenAPI document: 6.0.1
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, ConfigDict, StrictBool, StrictFloat, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional, Union
from lthn.models.maintainers_info_model import MaintainersInfoModel
from lthn.models.performance_model import PerformanceModel
from typing import Optional, Set
from typing_extensions import Self
class InfoModel(BaseModel):
"""
InfoModel
""" # noqa: E501
height: Optional[StrictInt] = None
tx_count: Optional[StrictInt] = None
tx_pool_size: Optional[StrictInt] = None
alt_blocks_count: Optional[StrictInt] = None
outgoing_connections_count: Optional[StrictInt] = None
incoming_connections_count: Optional[StrictInt] = None
synchronized_connections_count: Optional[StrictInt] = None
white_peerlist_size: Optional[StrictInt] = None
grey_peerlist_size: Optional[StrictInt] = None
current_blocks_median: Optional[StrictInt] = None
alias_count: Optional[StrictInt] = None
current_max_allowed_block_size: Optional[StrictInt] = None
daemon_network_state: Optional[StrictStr] = None
synchronization_start_height: Optional[StrictInt] = None
max_net_seen_height: Optional[StrictInt] = None
mi: Optional[MaintainersInfoModel] = None
pos_allowed: Optional[StrictBool] = None
pos_difficulty: Optional[StrictStr] = None
pow_difficulty: Optional[StrictInt] = None
default_fee: Optional[StrictInt] = None
minimum_fee: Optional[StrictInt] = None
is_hardfork_active: Optional[List[StrictBool]] = None
net_time_delta_median: Optional[StrictInt] = None
current_network_hashrate_50: Optional[StrictInt] = None
current_network_hashrate_350: Optional[StrictInt] = None
seconds_for_10_blocks: Optional[StrictInt] = None
seconds_for_30_blocks: Optional[StrictInt] = None
transactions_cnt_per_day: Optional[List[StrictInt]] = None
transactions_volume_per_day: Optional[List[StrictInt]] = None
last_pos_timestamp: Optional[StrictInt] = None
last_pow_timestamp: Optional[StrictInt] = None
total_coins: Optional[StrictStr] = None
last_block_size: Optional[StrictInt] = None
tx_count_in_last_block: Optional[StrictInt] = None
pos_sequence_factor: Optional[Union[StrictFloat, StrictInt]] = None
pow_sequence_factor: Optional[Union[StrictFloat, StrictInt]] = None
block_reward: Optional[StrictInt] = None
last_block_total_reward: Optional[StrictInt] = None
pos_diff_total_coins_rate: Optional[StrictInt] = None
last_block_timestamp: Optional[StrictInt] = None
last_block_hash: Optional[StrictStr] = None
pos_block_ts_shift_vs_actual: Optional[StrictInt] = None
outs_stat: Optional[Dict[str, StrictInt]] = None
performance_data: Optional[PerformanceModel] = None
offers_count: Optional[StrictInt] = None
expiration_median_timestamp: Optional[StrictInt] = None
__properties: ClassVar[List[str]] = ["height", "tx_count", "tx_pool_size", "alt_blocks_count", "outgoing_connections_count", "incoming_connections_count", "synchronized_connections_count", "white_peerlist_size", "grey_peerlist_size", "current_blocks_median", "alias_count", "current_max_allowed_block_size", "daemon_network_state", "synchronization_start_height", "max_net_seen_height", "mi", "pos_allowed", "pos_difficulty", "pow_difficulty", "default_fee", "minimum_fee", "is_hardfork_active", "net_time_delta_median", "current_network_hashrate_50", "current_network_hashrate_350", "seconds_for_10_blocks", "seconds_for_30_blocks", "transactions_cnt_per_day", "transactions_volume_per_day", "last_pos_timestamp", "last_pow_timestamp", "total_coins", "last_block_size", "tx_count_in_last_block", "pos_sequence_factor", "pow_sequence_factor", "block_reward", "last_block_total_reward", "pos_diff_total_coins_rate", "last_block_timestamp", "last_block_hash", "pos_block_ts_shift_vs_actual", "outs_stat", "performance_data", "offers_count", "expiration_median_timestamp"]
model_config = ConfigDict(
populate_by_name=True,
validate_assignment=True,
protected_namespaces=(),
)
def to_str(self) -> str:
"""Returns the string representation of the model using alias"""
return pprint.pformat(self.model_dump(by_alias=True))
def to_json(self) -> str:
"""Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict())
@classmethod
def from_json(cls, json_str: str) -> Optional[Self]:
"""Create an instance of InfoModel from a JSON string"""
return cls.from_dict(json.loads(json_str))
def to_dict(self) -> Dict[str, Any]:
"""Return the dictionary representation of the model using alias.
This has the following differences from calling pydantic's
`self.model_dump(by_alias=True)`:
* `None` is only added to the output dict for nullable fields that
were set at model initialization. Other fields with value `None`
are ignored.
"""
excluded_fields: Set[str] = set([
])
_dict = self.model_dump(
by_alias=True,
exclude=excluded_fields,
exclude_none=True,
)
# override the default output from pydantic by calling `to_dict()` of mi
if self.mi:
_dict['mi'] = self.mi.to_dict()
# override the default output from pydantic by calling `to_dict()` of performance_data
if self.performance_data:
_dict['performance_data'] = self.performance_data.to_dict()
return _dict
@classmethod
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
"""Create an instance of InfoModel from a dict"""
if obj is None:
return None
if not isinstance(obj, dict):
return cls.model_validate(obj)
_obj = cls.model_validate({
"height": obj.get("height"),
"tx_count": obj.get("tx_count"),
"tx_pool_size": obj.get("tx_pool_size"),
"alt_blocks_count": obj.get("alt_blocks_count"),
"outgoing_connections_count": obj.get("outgoing_connections_count"),
"incoming_connections_count": obj.get("incoming_connections_count"),
"synchronized_connections_count": obj.get("synchronized_connections_count"),
"white_peerlist_size": obj.get("white_peerlist_size"),
"grey_peerlist_size": obj.get("grey_peerlist_size"),
"current_blocks_median": obj.get("current_blocks_median"),
"alias_count": obj.get("alias_count"),
"current_max_allowed_block_size": obj.get("current_max_allowed_block_size"),
"daemon_network_state": obj.get("daemon_network_state"),
"synchronization_start_height": obj.get("synchronization_start_height"),
"max_net_seen_height": obj.get("max_net_seen_height"),
"mi": MaintainersInfoModel.from_dict(obj["mi"]) if obj.get("mi") is not None else None,
"pos_allowed": obj.get("pos_allowed"),
"pos_difficulty": obj.get("pos_difficulty"),
"pow_difficulty": obj.get("pow_difficulty"),
"default_fee": obj.get("default_fee"),
"minimum_fee": obj.get("minimum_fee"),
"is_hardfork_active": obj.get("is_hardfork_active"),
"net_time_delta_median": obj.get("net_time_delta_median"),
"current_network_hashrate_50": obj.get("current_network_hashrate_50"),
"current_network_hashrate_350": obj.get("current_network_hashrate_350"),
"seconds_for_10_blocks": obj.get("seconds_for_10_blocks"),
"seconds_for_30_blocks": obj.get("seconds_for_30_blocks"),
"transactions_cnt_per_day": obj.get("transactions_cnt_per_day"),
"transactions_volume_per_day": obj.get("transactions_volume_per_day"),
"last_pos_timestamp": obj.get("last_pos_timestamp"),
"last_pow_timestamp": obj.get("last_pow_timestamp"),
"total_coins": obj.get("total_coins"),
"last_block_size": obj.get("last_block_size"),
"tx_count_in_last_block": obj.get("tx_count_in_last_block"),
"pos_sequence_factor": obj.get("pos_sequence_factor"),
"pow_sequence_factor": obj.get("pow_sequence_factor"),
"block_reward": obj.get("block_reward"),
"last_block_total_reward": obj.get("last_block_total_reward"),
"pos_diff_total_coins_rate": obj.get("pos_diff_total_coins_rate"),
"last_block_timestamp": obj.get("last_block_timestamp"),
"last_block_hash": obj.get("last_block_hash"),
"pos_block_ts_shift_vs_actual": obj.get("pos_block_ts_shift_vs_actual"),
"outs_stat": obj.get("outs_stat"),
"performance_data": PerformanceModel.from_dict(obj["performance_data"]) if obj.get("performance_data") is not None else None,
"offers_count": obj.get("offers_count"),
"expiration_median_timestamp": obj.get("expiration_median_timestamp")
})
return _obj