# coding: utf-8

"""
    OidcVpAdapterBackend

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

    The version of the OpenAPI document: 1.0.0
    Contact: info@affinidi.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 typing import Any, Dict, List, Optional
from pydantic import BaseModel, Field, StrictBool, StrictStr, conlist
from affinidi_tdk_login_configuration_client.models.id_token_mapping_item import IdTokenMappingItem
from affinidi_tdk_login_configuration_client.models.login_configuration_client_metadata_input import LoginConfigurationClientMetadataInput
from affinidi_tdk_login_configuration_client.models.token_endpoint_auth_method import TokenEndpointAuthMethod

class UpdateLoginConfigurationInput(BaseModel):
    """
    UpdateLoginConfigurationInput
    """
    name: Optional[StrictStr] = Field(default=None, description="User defined login configuration name")
    redirect_uris: Optional[conlist(StrictStr)] = Field(default=None, alias="redirectUris", description="OAuth 2.0 Redirect URIs")
    post_logout_redirect_uris: Optional[conlist(StrictStr)] = Field(default=None, alias="postLogoutRedirectUris", description="Post Logout Redirect URIs, Used to redirect the user's browser to a specified URL after the logout process is complete. Must match the domain, port, scheme of at least one of the registered redirect URIs")
    client_secret: Optional[StrictStr] = Field(default=None, alias="clientSecret", description="OAuth2 client secret")
    vp_definition: Optional[StrictStr] = Field(default=None, alias="vpDefinition", description="VP definition in JSON stringify format")
    presentation_definition: Optional[Dict[str, Any]] = Field(default=None, alias="presentationDefinition", description="Presentation Definition")
    id_token_mapping: Optional[conlist(IdTokenMappingItem, min_items=1)] = Field(default=None, alias="idTokenMapping", description="Fields name/path mapping between the vp_token and the id_token")
    client_metadata: Optional[LoginConfigurationClientMetadataInput] = Field(default=None, alias="clientMetadata")
    token_endpoint_auth_method: Optional[TokenEndpointAuthMethod] = Field(default=None, alias="tokenEndpointAuthMethod")
    fail_on_mapping_conflict: Optional[StrictBool] = Field(default=None, alias="failOnMappingConflict", description="Interrupts login process if duplications of data fields names will be found")
    __properties = ["name", "redirectUris", "postLogoutRedirectUris", "clientSecret", "vpDefinition", "presentationDefinition", "idTokenMapping", "clientMetadata", "tokenEndpointAuthMethod", "failOnMappingConflict"]

    class Config:
        """Pydantic configuration"""
        allow_population_by_field_name = True
        validate_assignment = True

    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.dict(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> UpdateLoginConfigurationInput:
        """Create an instance of UpdateLoginConfigurationInput from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self):
        """Returns the dictionary representation of the model using alias"""
        _dict = self.dict(by_alias=True,
                          exclude={
                          },
                          exclude_none=True)
        # override the default output from pydantic by calling `to_dict()` of each item in id_token_mapping (list)
        _items = []
        if self.id_token_mapping:
            for _item in self.id_token_mapping:
                if _item:
                    _items.append(_item.to_dict())
            _dict['idTokenMapping'] = _items
        # override the default output from pydantic by calling `to_dict()` of client_metadata
        if self.client_metadata:
            _dict['clientMetadata'] = self.client_metadata.to_dict()
        return _dict

    @classmethod
    def from_dict(cls, obj: dict) -> UpdateLoginConfigurationInput:
        """Create an instance of UpdateLoginConfigurationInput from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return UpdateLoginConfigurationInput.parse_obj(obj)

        _obj = UpdateLoginConfigurationInput.parse_obj({
            "name": obj.get("name"),
            "redirect_uris": obj.get("redirectUris"),
            "post_logout_redirect_uris": obj.get("postLogoutRedirectUris"),
            "client_secret": obj.get("clientSecret"),
            "vp_definition": obj.get("vpDefinition"),
            "presentation_definition": obj.get("presentationDefinition"),
            "id_token_mapping": [IdTokenMappingItem.from_dict(_item) for _item in obj.get("idTokenMapping")] if obj.get("idTokenMapping") is not None else None,
            "client_metadata": LoginConfigurationClientMetadataInput.from_dict(obj.get("clientMetadata")) if obj.get("clientMetadata") is not None else None,
            "token_endpoint_auth_method": obj.get("tokenEndpointAuthMethod"),
            "fail_on_mapping_conflict": obj.get("failOnMappingConflict")
        })
        return _obj


