# 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, StrictBool, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from instana_client.models.location_status import LocationStatus
from typing import Optional, Set
from typing_extensions import Self

class TestCommonProperties(BaseModel):
    """
    TestCommonProperties
    """ # noqa: E501
    active: StrictBool
    application_id: Optional[StrictStr] = Field(default=None, alias="applicationId")
    application_ids: Optional[List[StrictStr]] = Field(default=None, alias="applicationIds")
    application_label: Optional[StrictStr] = Field(default=None, alias="applicationLabel")
    application_labels: Optional[List[StrictStr]] = Field(default=None, alias="applicationLabels")
    created_at: Optional[StrictInt] = Field(default=None, alias="createdAt")
    frequency: StrictInt
    get_website_labels: Optional[List[StrictStr]] = Field(default=None, alias="getWebsiteLabels")
    id: StrictStr
    label: StrictStr
    location_display_labels: Optional[List[StrictStr]] = Field(default=None, alias="locationDisplayLabels")
    location_ids: Optional[List[StrictStr]] = Field(default=None, alias="locationIds")
    location_labels: Optional[List[StrictStr]] = Field(default=None, alias="locationLabels")
    location_status_list: Optional[List[LocationStatus]] = Field(default=None, alias="locationStatusList")
    mobile_application_ids: Optional[List[StrictStr]] = Field(default=None, alias="mobileApplicationIds")
    mobile_application_labels: Optional[List[StrictStr]] = Field(default=None, alias="mobileApplicationLabels")
    modified_at: Optional[StrictInt] = Field(default=None, alias="modifiedAt")
    service_id: Optional[StrictStr] = Field(default=None, alias="serviceId")
    type: StrictStr
    website_ids: Optional[List[StrictStr]] = Field(default=None, alias="websiteIds")
    website_labels: Optional[List[StrictStr]] = Field(default=None, alias="websiteLabels")
    __properties: ClassVar[List[str]] = ["active", "applicationId", "applicationIds", "applicationLabel", "applicationLabels", "createdAt", "frequency", "getWebsiteLabels", "id", "label", "locationDisplayLabels", "locationIds", "locationLabels", "locationStatusList", "mobileApplicationIds", "mobileApplicationLabels", "modifiedAt", "serviceId", "type", "websiteIds", "websiteLabels"]

    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 TestCommonProperties 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 location_status_list (list)
        _items = []
        if self.location_status_list:
            for _item_location_status_list in self.location_status_list:
                if _item_location_status_list:
                    _items.append(_item_location_status_list.to_dict())
            _dict['locationStatusList'] = _items
        return _dict

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

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

        _obj = cls.model_validate({
            "active": obj.get("active"),
            "applicationId": obj.get("applicationId"),
            "applicationIds": obj.get("applicationIds"),
            "applicationLabel": obj.get("applicationLabel"),
            "applicationLabels": obj.get("applicationLabels"),
            "createdAt": obj.get("createdAt"),
            "frequency": obj.get("frequency"),
            "getWebsiteLabels": obj.get("getWebsiteLabels"),
            "id": obj.get("id"),
            "label": obj.get("label"),
            "locationDisplayLabels": obj.get("locationDisplayLabels"),
            "locationIds": obj.get("locationIds"),
            "locationLabels": obj.get("locationLabels"),
            "locationStatusList": [LocationStatus.from_dict(_item) for _item in obj["locationStatusList"]] if obj.get("locationStatusList") is not None else None,
            "mobileApplicationIds": obj.get("mobileApplicationIds"),
            "mobileApplicationLabels": obj.get("mobileApplicationLabels"),
            "modifiedAt": obj.get("modifiedAt"),
            "serviceId": obj.get("serviceId"),
            "type": obj.get("type"),
            "websiteIds": obj.get("websiteIds"),
            "websiteLabels": obj.get("websiteLabels")
        })
        return _obj


