# coding: utf-8

"""
    Graphiant APIs

    Graphiant API documentation.

    The version of the OpenAPI document: 1.0.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, StrictBool, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from graphiant_sdk.models.v1_activity_logs_post200_response_details_inner_targets_inner import V1ActivityLogsPost200ResponseDetailsInnerTargetsInner
from graphiant_sdk.models.v1_activity_logs_post_request_selector_job_entity import V1ActivityLogsPostRequestSelectorJobEntity
from graphiant_sdk.models.v1_alarm_history_get200_response_history_inner_time import V1AlarmHistoryGet200ResponseHistoryInnerTime
from typing import Optional, Set
from typing_extensions import Self

class V1ActivityLogsPost200ResponseDetailsInner(BaseModel):
    """
    V1ActivityLogsPost200ResponseDetailsInner
    """ # noqa: E501
    action: Optional[StrictStr] = None
    attributes: Optional[List[V1ActivityLogsPostRequestSelectorJobEntity]] = None
    category: Optional[StrictStr] = None
    disable_auto_timeout: Optional[StrictBool] = Field(default=None, alias="disableAutoTimeout")
    end_ts: Optional[V1AlarmHistoryGet200ResponseHistoryInnerTime] = Field(default=None, alias="endTs")
    enterprise_id: Optional[StrictInt] = Field(default=None, alias="enterpriseId")
    id: Optional[StrictStr] = None
    initiator_type: Optional[StrictStr] = Field(default=None, alias="initiatorType")
    job_entities: Optional[List[V1ActivityLogsPostRequestSelectorJobEntity]] = Field(default=None, alias="jobEntities")
    job_type: Optional[StrictStr] = Field(default=None, alias="jobType")
    original_enterprise_id: Optional[StrictInt] = Field(default=None, alias="originalEnterpriseId")
    start_ts: Optional[V1AlarmHistoryGet200ResponseHistoryInnerTime] = Field(default=None, alias="startTs")
    status: Optional[StrictStr] = None
    targets: Optional[List[V1ActivityLogsPost200ResponseDetailsInnerTargetsInner]] = None
    trace_session_id: Optional[StrictStr] = Field(default=None, alias="traceSessionId")
    usage: Optional[StrictStr] = None
    user: Optional[StrictStr] = None
    user_id: Optional[StrictStr] = Field(default=None, alias="userId")
    __properties: ClassVar[List[str]] = ["action", "attributes", "category", "disableAutoTimeout", "endTs", "enterpriseId", "id", "initiatorType", "jobEntities", "jobType", "originalEnterpriseId", "startTs", "status", "targets", "traceSessionId", "usage", "user", "userId"]

    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 V1ActivityLogsPost200ResponseDetailsInner 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 attributes (list)
        _items = []
        if self.attributes:
            for _item_attributes in self.attributes:
                if _item_attributes:
                    _items.append(_item_attributes.to_dict())
            _dict['attributes'] = _items
        # override the default output from pydantic by calling `to_dict()` of end_ts
        if self.end_ts:
            _dict['endTs'] = self.end_ts.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in job_entities (list)
        _items = []
        if self.job_entities:
            for _item_job_entities in self.job_entities:
                if _item_job_entities:
                    _items.append(_item_job_entities.to_dict())
            _dict['jobEntities'] = _items
        # override the default output from pydantic by calling `to_dict()` of start_ts
        if self.start_ts:
            _dict['startTs'] = self.start_ts.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in targets (list)
        _items = []
        if self.targets:
            for _item_targets in self.targets:
                if _item_targets:
                    _items.append(_item_targets.to_dict())
            _dict['targets'] = _items
        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of V1ActivityLogsPost200ResponseDetailsInner from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return cls.model_validate(obj)

        _obj = cls.model_validate({
            "action": obj.get("action"),
            "attributes": [V1ActivityLogsPostRequestSelectorJobEntity.from_dict(_item) for _item in obj["attributes"]] if obj.get("attributes") is not None else None,
            "category": obj.get("category"),
            "disableAutoTimeout": obj.get("disableAutoTimeout"),
            "endTs": V1AlarmHistoryGet200ResponseHistoryInnerTime.from_dict(obj["endTs"]) if obj.get("endTs") is not None else None,
            "enterpriseId": obj.get("enterpriseId"),
            "id": obj.get("id"),
            "initiatorType": obj.get("initiatorType"),
            "jobEntities": [V1ActivityLogsPostRequestSelectorJobEntity.from_dict(_item) for _item in obj["jobEntities"]] if obj.get("jobEntities") is not None else None,
            "jobType": obj.get("jobType"),
            "originalEnterpriseId": obj.get("originalEnterpriseId"),
            "startTs": V1AlarmHistoryGet200ResponseHistoryInnerTime.from_dict(obj["startTs"]) if obj.get("startTs") is not None else None,
            "status": obj.get("status"),
            "targets": [V1ActivityLogsPost200ResponseDetailsInnerTargetsInner.from_dict(_item) for _item in obj["targets"]] if obj.get("targets") is not None else None,
            "traceSessionId": obj.get("traceSessionId"),
            "usage": obj.get("usage"),
            "user": obj.get("user"),
            "userId": obj.get("userId")
        })
        return _obj


