# coding: utf-8

"""
    Instana REST API documentation

    Documentation for INSTANA REST API

    The version of the OpenAPI document: 1.309.1268
    Contact: support@instana.com
    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
from typing import Any, ClassVar, Dict, List, Optional
from typing import Optional, Set
from typing_extensions import Self

class BusinessActivity(BaseModel):
    """
    BusinessActivity
    """ # noqa: E501
    activity_id: Optional[StrictStr] = Field(default=None, description="Unique identifier for the activity generated by the source BPM tool", alias="activityId")
    activity_name: Optional[StrictStr] = Field(default=None, description="Name of the activity ", alias="activityName")
    activity_start: Optional[StrictInt] = Field(default=None, description="Unix timestamp representing the activity's start time", alias="activityStart")
    activity_type: StrictStr = Field(description="Type of the activity ", alias="activityType")
    call_id: Optional[StrictStr] = Field(default=None, alias="callId")
    endpoint_ids: Optional[List[StrictStr]] = Field(default=None, alias="endpointIds")
    process_definition_id: Optional[StrictStr] = Field(default=None, description="The identifier of the process the activity is an instance of.", alias="processDefinitionId")
    process_definition_name: Optional[StrictStr] = Field(default=None, description="The name of the process that the activity is an instance of", alias="processDefinitionName")
    root_process_instance_id: Optional[StrictStr] = Field(default=None, description="The id of the root process for the activity", alias="rootProcessInstanceId")
    __properties: ClassVar[List[str]] = ["activityId", "activityName", "activityStart", "activityType", "callId", "endpointIds", "processDefinitionId", "processDefinitionName", "rootProcessInstanceId"]

    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 BusinessActivity 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,
        )
        # set to None if activity_id (nullable) is None
        # and model_fields_set contains the field
        if self.activity_id is None and "activity_id" in self.model_fields_set:
            _dict['activityId'] = None

        # set to None if activity_name (nullable) is None
        # and model_fields_set contains the field
        if self.activity_name is None and "activity_name" in self.model_fields_set:
            _dict['activityName'] = None

        # set to None if activity_start (nullable) is None
        # and model_fields_set contains the field
        if self.activity_start is None and "activity_start" in self.model_fields_set:
            _dict['activityStart'] = None

        # set to None if process_definition_id (nullable) is None
        # and model_fields_set contains the field
        if self.process_definition_id is None and "process_definition_id" in self.model_fields_set:
            _dict['processDefinitionId'] = None

        # set to None if process_definition_name (nullable) is None
        # and model_fields_set contains the field
        if self.process_definition_name is None and "process_definition_name" in self.model_fields_set:
            _dict['processDefinitionName'] = None

        # set to None if root_process_instance_id (nullable) is None
        # and model_fields_set contains the field
        if self.root_process_instance_id is None and "root_process_instance_id" in self.model_fields_set:
            _dict['rootProcessInstanceId'] = None

        return _dict

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

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

        _obj = cls.model_validate({
            "activityId": obj.get("activityId"),
            "activityName": obj.get("activityName"),
            "activityStart": obj.get("activityStart"),
            "activityType": obj.get("activityType"),
            "callId": obj.get("callId"),
            "endpointIds": obj.get("endpointIds"),
            "processDefinitionId": obj.get("processDefinitionId"),
            "processDefinitionName": obj.get("processDefinitionName"),
            "rootProcessInstanceId": obj.get("rootProcessInstanceId")
        })
        return _obj


