Source code for openapi_client.models.query_workbook_details

# coding: utf-8

"""
    Amorphic Data Platform

    Amorphic Data Platform - API Definition documentation

    The version of the OpenAPI document: 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, ConfigDict, Field, StrictInt, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional
from openapi_client.models.query_response import QueryResponse
from openapi_client.models.query_workbook_details_chat_configuration import QueryWorkbookDetailsChatConfiguration
from openapi_client.models.query_workbook_message import QueryWorkbookMessage
from typing import Optional, Set
from typing_extensions import Self

[docs] class QueryWorkbookDetails(BaseModel): """ QueryWorkbookDetails """ # noqa: E501 workbook_id: Optional[StrictStr] = Field(default=None, description="Unique identifier for the workbook", alias="WorkbookId") title: Optional[StrictStr] = Field(default=None, description="Workbook title", alias="Title") creation_time: Optional[StrictStr] = Field(default=None, description="Workbook creation timestamp", alias="CreationTime") created_by: Optional[StrictStr] = Field(default=None, description="User who created the workbook", alias="CreatedBy") last_modified_by: Optional[StrictStr] = Field(default=None, description="User who last modified the workbook", alias="LastModifiedBy") last_modified_time: Optional[StrictStr] = Field(default=None, description="Last modification timestamp", alias="LastModifiedTime") chat_configuration: Optional[QueryWorkbookDetailsChatConfiguration] = Field(default=None, alias="ChatConfiguration") access_type: Optional[StrictStr] = Field(default=None, description="User's access level to the workbook", alias="AccessType") messages: Optional[List[QueryWorkbookMessage]] = None query_items: Optional[List[QueryResponse]] = None count: Optional[StrictInt] = Field(default=None, description="Number of messages in current page") total_count: Optional[StrictInt] = Field(default=None, description="Total number of messages available") next_available: Optional[StrictStr] = Field(default=None, description="Whether more pages are available") __properties: ClassVar[List[str]] = ["WorkbookId", "Title", "CreationTime", "CreatedBy", "LastModifiedBy", "LastModifiedTime", "ChatConfiguration", "AccessType", "messages", "query_items", "count", "total_count", "next_available"]
[docs] @field_validator('next_available') def next_available_validate_enum(cls, value): """Validates the enum""" if value is None: return value if value not in set(['yes', 'no']): raise ValueError("must be one of enum values ('yes', 'no')") return value
model_config = ConfigDict( populate_by_name=True, validate_assignment=True, protected_namespaces=(), )
[docs] def to_str(self) -> str: """Returns the string representation of the model using alias""" return pprint.pformat(self.model_dump(by_alias=True))
[docs] 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())
[docs] @classmethod def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of QueryWorkbookDetails from a JSON string""" return cls.from_dict(json.loads(json_str))
[docs] 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 chat_configuration if self.chat_configuration: _dict['ChatConfiguration'] = self.chat_configuration.to_dict() # override the default output from pydantic by calling `to_dict()` of each item in messages (list) _items = [] if self.messages: for _item_messages in self.messages: if _item_messages: _items.append(_item_messages.to_dict()) _dict['messages'] = _items # override the default output from pydantic by calling `to_dict()` of each item in query_items (list) _items = [] if self.query_items: for _item_query_items in self.query_items: if _item_query_items: _items.append(_item_query_items.to_dict()) _dict['query_items'] = _items return _dict
[docs] @classmethod def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: """Create an instance of QueryWorkbookDetails from a dict""" if obj is None: return None if not isinstance(obj, dict): return cls.model_validate(obj) _obj = cls.model_validate({ "WorkbookId": obj.get("WorkbookId"), "Title": obj.get("Title"), "CreationTime": obj.get("CreationTime"), "CreatedBy": obj.get("CreatedBy"), "LastModifiedBy": obj.get("LastModifiedBy"), "LastModifiedTime": obj.get("LastModifiedTime"), "ChatConfiguration": QueryWorkbookDetailsChatConfiguration.from_dict(obj["ChatConfiguration"]) if obj.get("ChatConfiguration") is not None else None, "AccessType": obj.get("AccessType"), "messages": [QueryWorkbookMessage.from_dict(_item) for _item in obj["messages"]] if obj.get("messages") is not None else None, "query_items": [QueryResponse.from_dict(_item) for _item in obj["query_items"]] if obj.get("query_items") is not None else None, "count": obj.get("count"), "total_count": obj.get("total_count"), "next_available": obj.get("next_available") }) return _obj