# coding: utf-8

"""
    HashiCorp Vault API

    HTTP API that gives you full access to Vault. All API routes are prefixed with `/v1/`.

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

class PkiGenerateInternalKeyRequest(BaseModel):
    """
    PkiGenerateInternalKeyRequest
    """ # noqa: E501
    key_bits: Optional[StrictInt] = Field(default=0, description="The number of bits to use. Allowed values are 0 (universal default); with rsa key_type: 2048 (default), 3072, or 4096; with ec key_type: 224, 256 (default), 384, or 521; ignored with ed25519.")
    key_name: Optional[StrictStr] = Field(default=None, description="Optional name to be used for this key")
    key_type: Optional[StrictStr] = Field(default='rsa', description="The type of key to use; defaults to RSA. \"rsa\" \"ec\" and \"ed25519\" are the only valid values.")
    managed_key_id: Optional[StrictStr] = Field(default=None, description="The name of the managed key to use when the exported type is kms. When kms type is the key type, this field or managed_key_name is required. Ignored for other types.")
    managed_key_name: Optional[StrictStr] = Field(default=None, description="The name of the managed key to use when the exported type is kms. When kms type is the key type, this field or managed_key_id is required. Ignored for other types.")
    __properties: ClassVar[List[str]] = ["key_bits", "key_name", "key_type", "managed_key_id", "managed_key_name"]

    @field_validator('key_type')
    def key_type_validate_enum(cls, value):
        """Validates the enum"""
        if value is None:
            return value

        if value not in set(['rsa', 'ec', 'ed25519']):
            raise ValueError("must be one of enum values ('rsa', 'ec', 'ed25519')")
        return value

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

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

        _obj = cls.model_validate({
            "key_bits": obj.get("key_bits") if obj.get("key_bits") is not None else 0,
            "key_name": obj.get("key_name"),
            "key_type": obj.get("key_type") if obj.get("key_type") is not None else 'rsa',
            "managed_key_id": obj.get("managed_key_id"),
            "managed_key_name": obj.get("managed_key_name")
        })
        return _obj


