1
0
Fork 0
forked from lthn/blockchain
blockchain/utils/sdk/client/python/lthn/models/block_details_model.py

145 lines
5.9 KiB
Python
Raw Permalink Normal View History

# 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, Field, StrictBool, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from typing_extensions import Annotated
from lthn.models.transaction_details_model import TransactionDetailsModel
from typing import Optional, Set
from typing_extensions import Self
class BlockDetailsModel(BaseModel):
"""
BlockDetailsModel
""" # noqa: E501
actual_timestamp: Optional[StrictInt] = None
already_generated_coins: Optional[StrictStr] = None
base_reward: Optional[StrictInt] = None
blob: Optional[StrictStr] = None
block_cumulative_size: Optional[StrictInt] = None
block_tself_size: Optional[StrictInt] = None
cumulative_diff_adjusted: Optional[StrictStr] = None
cumulative_diff_precise: Optional[StrictStr] = None
difficulty: Optional[StrictStr] = None
effective_fee_median: Optional[StrictInt] = None
height: Optional[StrictInt] = None
id: Optional[StrictStr] = None
is_orphan: Optional[StrictBool] = None
miner_text_info: Optional[StrictStr] = None
object_in_json: Optional[StrictStr] = None
penalty: Optional[StrictInt] = None
pow_seed: Optional[StrictStr] = None
prev_id: Optional[StrictStr] = None
summary_reward: Optional[StrictInt] = None
this_block_fee_median: Optional[StrictInt] = None
timestamp: Optional[StrictInt] = None
total_fee: Optional[StrictInt] = None
total_txs_size: Optional[StrictInt] = None
transactions_details: Optional[List[TransactionDetailsModel]] = None
type: Optional[Annotated[int, Field(le=4294967295, strict=True, ge=0)]] = None
__properties: ClassVar[List[str]] = ["actual_timestamp", "already_generated_coins", "base_reward", "blob", "block_cumulative_size", "block_tself_size", "cumulative_diff_adjusted", "cumulative_diff_precise", "difficulty", "effective_fee_median", "height", "id", "is_orphan", "miner_text_info", "object_in_json", "penalty", "pow_seed", "prev_id", "summary_reward", "this_block_fee_median", "timestamp", "total_fee", "total_txs_size", "transactions_details", "type"]
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 BlockDetailsModel 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 each item in transactions_details (list)
_items = []
if self.transactions_details:
for _item_transactions_details in self.transactions_details:
if _item_transactions_details:
_items.append(_item_transactions_details.to_dict())
_dict['transactions_details'] = _items
return _dict
@classmethod
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
"""Create an instance of BlockDetailsModel from a dict"""
if obj is None:
return None
if not isinstance(obj, dict):
return cls.model_validate(obj)
_obj = cls.model_validate({
"actual_timestamp": obj.get("actual_timestamp"),
"already_generated_coins": obj.get("already_generated_coins"),
"base_reward": obj.get("base_reward"),
"blob": obj.get("blob"),
"block_cumulative_size": obj.get("block_cumulative_size"),
"block_tself_size": obj.get("block_tself_size"),
"cumulative_diff_adjusted": obj.get("cumulative_diff_adjusted"),
"cumulative_diff_precise": obj.get("cumulative_diff_precise"),
"difficulty": obj.get("difficulty"),
"effective_fee_median": obj.get("effective_fee_median"),
"height": obj.get("height"),
"id": obj.get("id"),
"is_orphan": obj.get("is_orphan"),
"miner_text_info": obj.get("miner_text_info"),
"object_in_json": obj.get("object_in_json"),
"penalty": obj.get("penalty"),
"pow_seed": obj.get("pow_seed"),
"prev_id": obj.get("prev_id"),
"summary_reward": obj.get("summary_reward"),
"this_block_fee_median": obj.get("this_block_fee_median"),
"timestamp": obj.get("timestamp"),
"total_fee": obj.get("total_fee"),
"total_txs_size": obj.get("total_txs_size"),
"transactions_details": [TransactionDetailsModel.from_dict(_item) for _item in obj["transactions_details"]] if obj.get("transactions_details") is not None else None,
"type": obj.get("type")
})
return _obj