# 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_login_version import ApplicationServiceLoginVersion
from zitadel_client.models.application_service_oidc_application_type import ApplicationServiceOIDCApplicationType
from zitadel_client.models.application_service_oidc_auth_method_type import ApplicationServiceOIDCAuthMethodType
from zitadel_client.models.application_service_oidc_grant_type import ApplicationServiceOIDCGrantType
from zitadel_client.models.application_service_oidc_response_type import ApplicationServiceOIDCResponseType
from zitadel_client.models.application_service_oidc_token_type import ApplicationServiceOIDCTokenType
from zitadel_client.models.application_service_oidc_version import ApplicationServiceOIDCVersion
from typing import Optional, Set
from typing_extensions import Self

class ApplicationServiceCreateOIDCApplicationRequest(BaseModel):
    """
    ApplicationServiceCreateOIDCApplicationRequest
    """ # noqa: E501
    redirect_uris: Optional[List[StrictStr]] = Field(default=None, description="RedirectURIs are the allowed callback URIs for the OAuth2 / OIDC flows,  where the authorization code or tokens will be sent to.  The redirect_uri parameter in the authorization request must exactly match one of these URIs.", alias="redirectUris")
    response_types: Optional[List[ApplicationServiceOIDCResponseType]] = Field(default=None, description="ResponseTypes define whether a code, id_token token or just id_token will be returned.  The response_type parameter in the authorization request must exactly match one of these values.", alias="responseTypes")
    grant_types: Optional[List[ApplicationServiceOIDCGrantType]] = Field(default=None, description="GrantTypes define the flow type the application is allowed to use.  The grant_type parameter in the token request must exactly match one of these values.  Minimum one grant type must be provided, but multiple grant types can be provided to allow  different flows, e.g. authorization code flow and refresh token flow.", alias="grantTypes")
    application_type: Optional[ApplicationServiceOIDCApplicationType] = Field(default=None, alias="applicationType")
    auth_method_type: Optional[ApplicationServiceOIDCAuthMethodType] = Field(default=None, alias="authMethodType")
    post_logout_redirect_uris: Optional[List[StrictStr]] = Field(default=None, description="PostLogoutRedirectURIs are the allowed URIs to redirect to after a logout.  The post_logout_redirect_uri parameter in the logout request must exactly match one of these URIs.", alias="postLogoutRedirectUris")
    version: Optional[ApplicationServiceOIDCVersion] = None
    development_mode: Optional[StrictBool] = Field(default=None, description="DevelopmentMode can be enabled for development purposes. This allows the use of  OIDC non-compliant and potentially insecure settings, such as the use of  HTTP redirect URIs or wildcard redirect URIs.", alias="developmentMode")
    access_token_type: Optional[ApplicationServiceOIDCTokenType] = Field(default=None, alias="accessTokenType")
    access_token_role_assertion: Optional[StrictBool] = Field(default=None, description="If AccessTokenRoleAssertion is enabled, the roles of the user are added to the access token.  Ensure that the access token is a JWT token and not a bearer token. And either request the roles  by scope or enable the user role assertion on the project.", alias="accessTokenRoleAssertion")
    id_token_role_assertion: Optional[StrictBool] = Field(default=None, description="If IDTokenRoleAssertion is enabled, the roles of the user are added to the id token.  Ensure that either the roles are requested by scope or enable the user role assertion on the  project.", alias="idTokenRoleAssertion")
    id_token_userinfo_assertion: Optional[StrictBool] = Field(default=None, description="If IDTokenUserinfoAssertion is enabled, the claims of profile, email, address and phone scopes  are added to the id token even if an access token is issued. This can be required by some applications  that do not call the userinfo endpoint after authentication or directly use the id_token for retrieving  user information.  Attention: this violates the OIDC specification, which states that these claims must only be  requested from the userinfo endpoint if an access token is issued. This is to prevent  leaking of personal information in the id token, which is often stored in the browser and  therefore more vulnerable.", alias="idTokenUserinfoAssertion")
    clock_skew: Optional[StrictStr] = Field(default=None, description="A Duration represents a signed, fixed-length span of time represented  as a count of seconds and fractions of seconds at nanosecond  resolution. It is independent of any calendar and concepts like \"day\"  or \"month\". It is related to Timestamp in that the difference between  two Timestamp values is a Duration and it can be added or subtracted  from a Timestamp. Range is approximately +-10,000 years.   # Examples   Example 1: Compute Duration from two Timestamps in pseudo code.       Timestamp start = ...;      Timestamp end = ...;      Duration duration = ...;       duration.seconds = end.seconds - start.seconds;      duration.nanos = end.nanos - start.nanos;       if (duration.seconds < 0 && duration.nanos > 0) {        duration.seconds += 1;        duration.nanos -= 1000000000;      } else if (duration.seconds > 0 && duration.nanos < 0) {        duration.seconds -= 1;        duration.nanos += 1000000000;      }   Example 2: Compute Timestamp from Timestamp + Duration in pseudo code.       Timestamp start = ...;      Duration duration = ...;      Timestamp end = ...;       end.seconds = start.seconds + duration.seconds;      end.nanos = start.nanos + duration.nanos;       if (end.nanos < 0) {        end.seconds -= 1;        end.nanos += 1000000000;      } else if (end.nanos >= 1000000000) {        end.seconds += 1;        end.nanos -= 1000000000;      }   Example 3: Compute Duration from datetime.timedelta in Python.       td = datetime.timedelta(days=3, minutes=10)      duration = Duration()      duration.FromTimedelta(td)   # JSON Mapping   In JSON format, the Duration type is encoded as a string rather than an  object, where the string ends in the suffix \"s\" (indicating seconds) and  is preceded by the number of seconds, with nanoseconds expressed as  fractional seconds. For example, 3 seconds with 0 nanoseconds should be  encoded in JSON format as \"3s\", while 3 seconds and 1 nanosecond should  be expressed in JSON format as \"3.000000001s\", and 3 seconds and 1  microsecond should be expressed in JSON format as \"3.000001s\".", alias="clockSkew")
    additional_origins: Optional[List[StrictStr]] = Field(default=None, description="AdditionalOrigins are HTTP origins (scheme + host + port) from where the API can be used  additional to the redirect_uris.  This is useful if the application is used from an origin different to the redirect_uris,  e.g. if the application is a SPA served in a native app, where the redirect_uri is a custom scheme,  but the application is served from a https origin.", alias="additionalOrigins")
    skip_native_app_success_page: Optional[StrictBool] = Field(default=None, description="For native apps a successful login usually shows a success page with a link to open the application again.  SkipNativeAppSuccessPage can be used to skip this page and open the application directly.", alias="skipNativeAppSuccessPage")
    back_channel_logout_uri: Optional[StrictStr] = Field(default=None, description="BackChannelLogoutURI is used to notify the application about terminated sessions according  to the OIDC Back-Channel Logout (https://openid.net/specs/openid-connect-backchannel-1_0.html).", alias="backChannelLogoutUri")
    login_version: Optional[ApplicationServiceLoginVersion] = Field(default=None, alias="loginVersion")
    __properties: ClassVar[List[str]] = ["redirectUris", "responseTypes", "grantTypes", "applicationType", "authMethodType", "postLogoutRedirectUris", "version", "developmentMode", "accessTokenType", "accessTokenRoleAssertion", "idTokenRoleAssertion", "idTokenUserinfoAssertion", "clockSkew", "additionalOrigins", "skipNativeAppSuccessPage", "backChannelLogoutUri", "loginVersion"]

    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 ApplicationServiceCreateOIDCApplicationRequest 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 login_version
        if self.login_version:
            _dict['loginVersion'] = self.login_version.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "redirectUris": obj.get("redirectUris"),
            "responseTypes": obj.get("responseTypes"),
            "grantTypes": obj.get("grantTypes"),
            "applicationType": obj.get("applicationType"),
            "authMethodType": obj.get("authMethodType"),
            "postLogoutRedirectUris": obj.get("postLogoutRedirectUris"),
            "version": obj.get("version"),
            "developmentMode": obj.get("developmentMode"),
            "accessTokenType": obj.get("accessTokenType"),
            "accessTokenRoleAssertion": obj.get("accessTokenRoleAssertion"),
            "idTokenRoleAssertion": obj.get("idTokenRoleAssertion"),
            "idTokenUserinfoAssertion": obj.get("idTokenUserinfoAssertion"),
            "clockSkew": obj.get("clockSkew"),
            "additionalOrigins": obj.get("additionalOrigins"),
            "skipNativeAppSuccessPage": obj.get("skipNativeAppSuccessPage"),
            "backChannelLogoutUri": obj.get("backChannelLogoutUri"),
            "loginVersion": ApplicationServiceLoginVersion.from_dict(obj["loginVersion"]) if obj.get("loginVersion") is not None else None
        })
        return _obj


