Source code for openapi_client.models.knowledge_base_detail

# coding: utf-8

"""
    Amorphic Data Platform

    Amorphic Data Platform - API Definition documentation

    The version of the OpenAPI document: 0.3.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 datetime import datetime
from pydantic import BaseModel, ConfigDict, Field, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from openapi_client.models.knowledge_base_detail_metrics import KnowledgeBaseDetailMetrics
from openapi_client.models.source_detail import SourceDetail
from typing import Optional, Set
from typing_extensions import Self

[docs] class KnowledgeBaseDetail(BaseModel): """ Detailed information about a knowledge base, including its associated data sources. """ # noqa: E501 knowledgebase_id: Optional[StrictStr] = Field(default=None, description="The unique identifier of the knowledge base.", alias="KnowledgebaseId") knowledgebase_name: Optional[StrictStr] = Field(default=None, description="The name of the knowledge base.", alias="KnowledgebaseName") embedding_model: Optional[StrictStr] = Field(default=None, description="The embedding model used for the knowledge base.", alias="EmbeddingModel") description: Optional[StrictStr] = Field(default=None, description="The description of the knowledge base.", alias="Description") knowledgebase_status: Optional[StrictStr] = Field(default=None, description="The current status of the knowledge base (e.g., CREATING, ACTIVE, FAILED).", alias="KnowledgebaseStatus") creation_time: Optional[datetime] = Field(default=None, description="Timestamp when the knowledge base was created.", alias="CreationTime") created_by: Optional[StrictStr] = Field(default=None, description="The ID of the user who created the knowledge base.", alias="CreatedBy") last_modified_time: Optional[datetime] = Field(default=None, description="Timestamp when the knowledge base was last modified.", alias="LastModifiedTime") last_modified_by: Optional[StrictStr] = Field(default=None, description="The ID of the user who last modified the knowledge base.", alias="LastModifiedBy") last_synced_time: Optional[datetime] = Field(default=None, description="Timestamp of the last successful synchronization. 'N/A' if never synced.", alias="LastSyncedTime") last_synced_status: Optional[StrictStr] = Field(default=None, description="Status of the last synchronization attempt (e.g., SUCCEEDED, FAILED). 'N/A' if never synced.", alias="LastSyncedStatus") keywords: Optional[List[StrictStr]] = Field(default=None, description="List of keywords associated with the knowledge base.", alias="Keywords") sort_key: Optional[StrictStr] = Field(default=None, description="The sort key used for organizing the knowledge base.", alias="SortKey") access_type: Optional[StrictStr] = Field(default=None, description="The access type for the knowledge base (e.g., owner, shared).", alias="AccessType") metrics: Optional[KnowledgeBaseDetailMetrics] = Field(default=None, alias="Metrics") source_details: Optional[List[SourceDetail]] = Field(default=None, description="A list of data sources associated with this knowledge base.", alias="SourceDetails") __properties: ClassVar[List[str]] = ["KnowledgebaseId", "KnowledgebaseName", "EmbeddingModel", "Description", "KnowledgebaseStatus", "CreationTime", "CreatedBy", "LastModifiedTime", "LastModifiedBy", "LastSyncedTime", "LastSyncedStatus", "Keywords", "SortKey", "AccessType", "Metrics", "SourceDetails"] 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 KnowledgeBaseDetail 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 metrics if self.metrics: _dict['Metrics'] = self.metrics.to_dict() # override the default output from pydantic by calling `to_dict()` of each item in source_details (list) _items = [] if self.source_details: for _item_source_details in self.source_details: if _item_source_details: _items.append(_item_source_details.to_dict()) _dict['SourceDetails'] = _items return _dict
[docs] @classmethod def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: """Create an instance of KnowledgeBaseDetail from a dict""" if obj is None: return None if not isinstance(obj, dict): return cls.model_validate(obj) _obj = cls.model_validate({ "KnowledgebaseId": obj.get("KnowledgebaseId"), "KnowledgebaseName": obj.get("KnowledgebaseName"), "EmbeddingModel": obj.get("EmbeddingModel"), "Description": obj.get("Description"), "KnowledgebaseStatus": obj.get("KnowledgebaseStatus"), "CreationTime": obj.get("CreationTime"), "CreatedBy": obj.get("CreatedBy"), "LastModifiedTime": obj.get("LastModifiedTime"), "LastModifiedBy": obj.get("LastModifiedBy"), "LastSyncedTime": obj.get("LastSyncedTime"), "LastSyncedStatus": obj.get("LastSyncedStatus"), "Keywords": obj.get("Keywords"), "SortKey": obj.get("SortKey"), "AccessType": obj.get("AccessType"), "Metrics": KnowledgeBaseDetailMetrics.from_dict(obj["Metrics"]) if obj.get("Metrics") is not None else None, "SourceDetails": [SourceDetail.from_dict(_item) for _item in obj["SourceDetails"]] if obj.get("SourceDetails") is not None else None }) return _obj