# coding: utf-8

"""
    Zitadel SDK

    The Zitadel SDK is a convenience wrapper around the Zitadel APIs to assist you in integrating with your Zitadel environment. This SDK enables you to handle resources, settings, and configurations within the Zitadel platform.

    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, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from zitadel_client.models.application_service_oidc_localized_message import ApplicationServiceOIDCLocalizedMessage
from typing import Optional, Set
from typing_extensions import Self

class ApplicationServiceCreateOIDCApplicationResponse(BaseModel):
    """
    ApplicationServiceCreateOIDCApplicationResponse
    """ # noqa: E501
    client_id: Optional[StrictStr] = Field(default=None, description="The unique OAuth2/OIDC client_id used for authentication of the application,  e.g. at the token endpoint.", alias="clientId")
    client_secret: Optional[StrictStr] = Field(default=None, description="In case of using the OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_CLIENT_SECRET_BASIC  or OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_CLIENT_SECRET_POST the client_secret is generated and returned.  It must be stored safely, as it will not be possible to retrieve it again.  A new client_secret can be generated using the GenerateClientSecret endpoint.", alias="clientSecret")
    non_compliant: Optional[StrictBool] = Field(default=None, description="NonCompliant specifies whether the config is OIDC compliant. A production configuration SHOULD be compliant.  Non-compliant configurations can run into interoperability issues with OIDC libraries and tools.  Compliance problems are listed in the compliance_problems field.", alias="nonCompliant")
    compliance_problems: Optional[List[ApplicationServiceOIDCLocalizedMessage]] = Field(default=None, description="ComplianceProblems lists the problems for non-compliant configurations.  In case of a compliant configuration, this list is empty.", alias="complianceProblems")
    __properties: ClassVar[List[str]] = ["clientId", "clientSecret", "nonCompliant", "complianceProblems"]

    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 ApplicationServiceCreateOIDCApplicationResponse 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 compliance_problems (list)
        _items = []
        if self.compliance_problems:
            for _item_compliance_problems in self.compliance_problems:
                if _item_compliance_problems:
                    _items.append(_item_compliance_problems.to_dict())
            _dict['complianceProblems'] = _items
        return _dict

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

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

        _obj = cls.model_validate({
            "clientId": obj.get("clientId"),
            "clientSecret": obj.get("clientSecret"),
            "nonCompliant": obj.get("nonCompliant"),
            "complianceProblems": [ApplicationServiceOIDCLocalizedMessage.from_dict(_item) for _item in obj["complianceProblems"]] if obj.get("complianceProblems") is not None else None
        })
        return _obj


