# coding: utf-8

"""
    STACKIT Observability API

    API endpoints for Observability on STACKIT

    The version of the OpenAPI document: 1.1.1
    Contact: stackit-argus@mail.schwarz
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501

from __future__ import annotations

import json
import pprint
from typing import Any, ClassVar, Dict, List, Optional, Set

from pydantic import BaseModel, ConfigDict, Field, StrictBool
from typing_extensions import Annotated, Self

from stackit.observability.models.plan_model import PlanModel


class InstanceSensitiveData(BaseModel):
    """
    InstanceSensitiveData
    """  # noqa: E501

    alerting_url: Annotated[str, Field(min_length=1, strict=True)] = Field(alias="alertingUrl")
    cluster: Annotated[str, Field(min_length=1, strict=True, max_length=63)]
    dashboard_url: Annotated[str, Field(min_length=1, strict=True)] = Field(alias="dashboardUrl")
    grafana_admin_enabled: StrictBool = Field(alias="grafanaAdminEnabled")
    grafana_admin_password: Annotated[str, Field(min_length=32, strict=True)] = Field(alias="grafanaAdminPassword")
    grafana_admin_user: Annotated[str, Field(min_length=1, strict=True)] = Field(alias="grafanaAdminUser")
    grafana_public_read_access: StrictBool = Field(alias="grafanaPublicReadAccess")
    grafana_url: Annotated[str, Field(min_length=1, strict=True)] = Field(alias="grafanaUrl")
    grafana_use_stackit_sso: StrictBool = Field(alias="grafanaUseStackitSso")
    instance: Annotated[str, Field(min_length=1, strict=True, max_length=63)]
    jaeger_http_traces_url: Optional[Annotated[str, Field(min_length=1, strict=True)]] = Field(
        default=None, alias="jaegerHttpTracesUrl"
    )
    jaeger_http_url: Annotated[str, Field(min_length=1, strict=True)] = Field(alias="jaegerHttpUrl")
    jaeger_traces_url: Annotated[str, Field(min_length=1, strict=True)] = Field(alias="jaegerTracesUrl")
    jaeger_ui_url: Annotated[str, Field(min_length=1, strict=True)] = Field(alias="jaegerUiUrl")
    logs_push_url: Annotated[str, Field(min_length=1, strict=True)] = Field(alias="logsPushUrl")
    logs_url: Annotated[str, Field(min_length=1, strict=True)] = Field(alias="logsUrl")
    metrics_endpoint_url: Annotated[str, Field(min_length=1, strict=True)] = Field(alias="metricsEndpointUrl")
    metrics_retention_time1h: Annotated[int, Field(strict=True, ge=0)] = Field(alias="metricsRetentionTime1h")
    metrics_retention_time5m: Annotated[int, Field(strict=True, ge=0)] = Field(alias="metricsRetentionTime5m")
    metrics_retention_time_raw: Annotated[int, Field(strict=True, ge=0)] = Field(alias="metricsRetentionTimeRaw")
    metrics_url: Annotated[str, Field(min_length=1, strict=True)] = Field(alias="metricsUrl")
    name: Optional[Annotated[str, Field(strict=True, max_length=300)]] = ""
    otlp_grpc_traces_url: Annotated[str, Field(min_length=1, strict=True)] = Field(alias="otlpGrpcTracesUrl")
    otlp_http_traces_url: Annotated[str, Field(min_length=1, strict=True)] = Field(alias="otlpHttpTracesUrl")
    otlp_traces_url: Annotated[str, Field(min_length=1, strict=True)] = Field(alias="otlpTracesUrl")
    plan: PlanModel
    push_metrics_url: Annotated[str, Field(min_length=1, strict=True)] = Field(alias="pushMetricsUrl")
    targets_url: Annotated[str, Field(min_length=1, strict=True)] = Field(alias="targetsUrl")
    zipkin_spans_url: Annotated[str, Field(min_length=1, strict=True)] = Field(alias="zipkinSpansUrl")
    __properties: ClassVar[List[str]] = [
        "alertingUrl",
        "cluster",
        "dashboardUrl",
        "grafanaAdminEnabled",
        "grafanaAdminPassword",
        "grafanaAdminUser",
        "grafanaPublicReadAccess",
        "grafanaUrl",
        "grafanaUseStackitSso",
        "instance",
        "jaegerHttpTracesUrl",
        "jaegerHttpUrl",
        "jaegerTracesUrl",
        "jaegerUiUrl",
        "logsPushUrl",
        "logsUrl",
        "metricsEndpointUrl",
        "metricsRetentionTime1h",
        "metricsRetentionTime5m",
        "metricsRetentionTimeRaw",
        "metricsUrl",
        "name",
        "otlpGrpcTracesUrl",
        "otlpHttpTracesUrl",
        "otlpTracesUrl",
        "plan",
        "pushMetricsUrl",
        "targetsUrl",
        "zipkinSpansUrl",
    ]

    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 InstanceSensitiveData 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 plan
        if self.plan:
            _dict["plan"] = self.plan.to_dict()
        return _dict

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

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

        _obj = cls.model_validate(
            {
                "alertingUrl": obj.get("alertingUrl"),
                "cluster": obj.get("cluster"),
                "dashboardUrl": obj.get("dashboardUrl"),
                "grafanaAdminEnabled": (
                    obj.get("grafanaAdminEnabled") if obj.get("grafanaAdminEnabled") is not None else True
                ),
                "grafanaAdminPassword": obj.get("grafanaAdminPassword"),
                "grafanaAdminUser": obj.get("grafanaAdminUser"),
                "grafanaPublicReadAccess": obj.get("grafanaPublicReadAccess"),
                "grafanaUrl": obj.get("grafanaUrl"),
                "grafanaUseStackitSso": obj.get("grafanaUseStackitSso"),
                "instance": obj.get("instance"),
                "jaegerHttpTracesUrl": obj.get("jaegerHttpTracesUrl"),
                "jaegerHttpUrl": obj.get("jaegerHttpUrl"),
                "jaegerTracesUrl": obj.get("jaegerTracesUrl"),
                "jaegerUiUrl": obj.get("jaegerUiUrl"),
                "logsPushUrl": obj.get("logsPushUrl"),
                "logsUrl": obj.get("logsUrl"),
                "metricsEndpointUrl": obj.get("metricsEndpointUrl"),
                "metricsRetentionTime1h": obj.get("metricsRetentionTime1h"),
                "metricsRetentionTime5m": obj.get("metricsRetentionTime5m"),
                "metricsRetentionTimeRaw": obj.get("metricsRetentionTimeRaw"),
                "metricsUrl": obj.get("metricsUrl"),
                "name": obj.get("name") if obj.get("name") is not None else "",
                "otlpGrpcTracesUrl": obj.get("otlpGrpcTracesUrl"),
                "otlpHttpTracesUrl": obj.get("otlpHttpTracesUrl"),
                "otlpTracesUrl": obj.get("otlpTracesUrl"),
                "plan": PlanModel.from_dict(obj["plan"]) if obj.get("plan") is not None else None,
                "pushMetricsUrl": obj.get("pushMetricsUrl"),
                "targetsUrl": obj.get("targetsUrl"),
                "zipkinSpansUrl": obj.get("zipkinSpansUrl"),
            }
        )
        return _obj
