# 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_extensions import Annotated
from instana_client.models.synthetic_geo_point import SyntheticGeoPoint
from instana_client.models.synthetic_location_configuration import SyntheticLocationConfiguration
from instana_client.models.synthetic_playback_capabilities import SyntheticPlaybackCapabilities
from typing import Optional, Set
from typing_extensions import Self

class SyntheticLocation(BaseModel):
    """
    SyntheticLocation
    """ # noqa: E501
    configuration: Optional[SyntheticLocationConfiguration] = None
    created_at: Optional[StrictInt] = Field(default=None, alias="createdAt")
    custom_properties: Optional[Dict[str, StrictStr]] = Field(default=None, alias="customProperties")
    description: Optional[Annotated[str, Field(min_length=0, strict=True, max_length=512)]] = None
    display_label: Optional[Annotated[str, Field(min_length=1, strict=True, max_length=128)]] = Field(default=None, alias="displayLabel")
    geo_point: SyntheticGeoPoint = Field(alias="geoPoint")
    id: Optional[Annotated[str, Field(min_length=0, strict=True, max_length=128)]] = None
    label: Annotated[str, Field(min_length=1, strict=True, max_length=128)]
    location_type: StrictStr = Field(alias="locationType")
    modified_at: Optional[StrictInt] = Field(default=None, alias="modifiedAt")
    observed_at: Optional[StrictInt] = Field(default=None, alias="observedAt")
    playback_capabilities: SyntheticPlaybackCapabilities = Field(alias="playbackCapabilities")
    pop_version: Optional[Annotated[str, Field(min_length=1, strict=True, max_length=64)]] = Field(default=None, alias="popVersion")
    status: Optional[StrictStr] = None
    total_tests: Optional[StrictInt] = Field(default=None, alias="totalTests")
    __properties: ClassVar[List[str]] = ["configuration", "createdAt", "customProperties", "description", "displayLabel", "geoPoint", "id", "label", "locationType", "modifiedAt", "observedAt", "playbackCapabilities", "popVersion", "status", "totalTests"]

    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 SyntheticLocation 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 configuration
        if self.configuration:
            _dict['configuration'] = self.configuration.to_dict()
        # override the default output from pydantic by calling `to_dict()` of geo_point
        if self.geo_point:
            _dict['geoPoint'] = self.geo_point.to_dict()
        # override the default output from pydantic by calling `to_dict()` of playback_capabilities
        if self.playback_capabilities:
            _dict['playbackCapabilities'] = self.playback_capabilities.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "configuration": SyntheticLocationConfiguration.from_dict(obj["configuration"]) if obj.get("configuration") is not None else None,
            "createdAt": obj.get("createdAt"),
            "customProperties": obj.get("customProperties"),
            "description": obj.get("description"),
            "displayLabel": obj.get("displayLabel"),
            "geoPoint": SyntheticGeoPoint.from_dict(obj["geoPoint"]) if obj.get("geoPoint") is not None else None,
            "id": obj.get("id"),
            "label": obj.get("label"),
            "locationType": obj.get("locationType"),
            "modifiedAt": obj.get("modifiedAt"),
            "observedAt": obj.get("observedAt"),
            "playbackCapabilities": SyntheticPlaybackCapabilities.from_dict(obj["playbackCapabilities"]) if obj.get("playbackCapabilities") is not None else None,
            "popVersion": obj.get("popVersion"),
            "status": obj.get("status"),
            "totalTests": obj.get("totalTests")
        })
        return _obj


