# coding: utf-8

"""
    Canva Connect API

    API for building integrations with Canva via a REST api

    The version of the OpenAPI document: latest
    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, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from typing import Optional, Set
from typing_extensions import Self

class JsonWebKey(BaseModel):
    """
    Standard Json Web Key specification following https://www.rfc-editor.org/rfc/rfc7517 and https://www.rfc-editor.org/rfc/rfc7518.html.
    """ # noqa: E501
    alg: Optional[StrictStr] = Field(default=None, description="The \"alg\" (algorithm) parameter identifies the algorithm intended for use with the key. See https://www.rfc-editor.org/rfc/rfc7517#section-4")
    kid: StrictStr = Field(description="The \"kid\" (key ID) parameter is used to match a specific key.  This is used, for instance, to choose among a set of keys within a JWK Set during key rollover. When \"kid\" values are used within a JWK Set, different keys within the JWK Set SHOULD use distinct \"kid\" values. The \"kid\" value is a case-sensitive string. See https://www.rfc-editor.org/rfc/rfc7517#section-4")
    kty: StrictStr = Field(description="The \"kty\" (key type) parameter identifies the cryptographic algorithm family used with the key, such as \"RSA\" or \"EC\". The \"kty\" value is a case-sensitive string. At the moment, only \"RSA\" is supported. See https://www.rfc-editor.org/rfc/rfc7517#section-4")
    n: StrictStr = Field(description="The \"n\" (modulus) parameter contains the modulus value for the RSA    public key.  It is represented as a Base64urlUInt-encoded value. See https://www.rfc-editor.org/rfc/rfc7518.html#section-6.3")
    e: StrictStr = Field(description="The \"e\" (exponent) parameter contains the exponent value for the RSA    public key.  It is represented as a Base64urlUInt-encoded value. See https://www.rfc-editor.org/rfc/rfc7518.html#section-6.3")
    use: Optional[StrictStr] = Field(default=None, description="The \"use\" (public key use) parameter identifies the intended use of the public key. The \"use\" parameter is employed to indicate whether a public key is used for encrypting data or verifying the signature on data. Values are commonly \"sig\" (signature) or \"enc\" (encryption). See https://www.rfc-editor.org/rfc/rfc7517#section-4")
    __properties: ClassVar[List[str]] = ["alg", "kid", "kty", "n", "e", "use"]

    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 JsonWebKey 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,
        )
        return _dict

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

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

        _obj = cls.model_validate({
            "alg": obj.get("alg"),
            "kid": obj.get("kid"),
            "kty": obj.get("kty"),
            "n": obj.get("n"),
            "e": obj.get("e"),
            "use": obj.get("use")
        })
        return _obj


