# 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
from typing import Optional, Set
from typing_extensions import Self

class EdDsaJwk(BaseModel):
    """
    A JSON Web Key Set (JWKS) using the Edwards-curve Digital Signature Algorithm (EdDSA), as described in [RFC-8037](https://www.rfc-editor.org/rfc/rfc8037.html#appendix-A).
    """ # noqa: E501
    kid: StrictStr = Field(description="The `kid` (key ID) is a unique identifier for a public key. When the keys used to sign webhooks are rotated, you can use this ID to select the correct key within a JWK Set during the key rollover. The `kid` value is case-sensitive.")
    kty: StrictStr = Field(description="The `kty` (key type) identifies the cryptographic algorithm family used with the key, such as \"RSA\" or \"EC\". Only Octet Key Pairs (`OKPs`) are supported. The `kty` value is case-sensitive. For more information on the `kty` property and OKPs, see [RFC-8037 — \"kty\" (Key Type) Parameter](https://www.rfc-editor.org/rfc/rfc8037.html#section-2).")
    crv: StrictStr = Field(description="The `crv` (curve) property identifies the curve used for elliptical curve encryptions. Only \"Ed25519\" is supported. For more information on the `crv` property, see [RFC-8037 — Key Type \"OKP\"](https://www.rfc-editor.org/rfc/rfc8037.html#section-2).")
    x: StrictStr = Field(description="The `x` property is the public key of an elliptical curve encryption. The key is Base64urlUInt-encoded. For more information on the `x` property, see [RFC-8037 — \"x\" (X Coordinate) Parameter](https://www.rfc-editor.org/rfc/rfc8037#section-2).")
    __properties: ClassVar[List[str]] = ["kid", "kty", "crv", "x"]

    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 EdDsaJwk 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 EdDsaJwk from a dict"""
        if obj is None:
            return None

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

        _obj = cls.model_validate({
            "kid": obj.get("kid"),
            "kty": obj.get("kty"),
            "crv": obj.get("crv"),
            "x": obj.get("x")
        })
        return _obj


