# 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, StrictBool, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from typing import Optional, Set
from typing_extensions import Self

class TotpCreateKeyRequest(BaseModel):
    """
    TotpCreateKeyRequest
    """ # noqa: E501
    account_name: Optional[StrictStr] = Field(default=None, description="The name of the account associated with the key. Required if generate is true.")
    algorithm: Optional[StrictStr] = Field(default='SHA1', description="The hashing algorithm used to generate the TOTP token. Options include SHA1, SHA256 and SHA512.")
    digits: Optional[StrictInt] = Field(default=6, description="The number of digits in the generated TOTP token. This value can either be 6 or 8.")
    exported: Optional[StrictBool] = Field(default=True, description="Determines if a QR code and url are returned upon generating a key. Only used if generate is true.")
    generate: Optional[StrictBool] = Field(default=False, description="Determines if a key should be generated by Vault or if a key is being passed from another service.")
    issuer: Optional[StrictStr] = Field(default=None, description="The name of the key's issuing organization. Required if generate is true.")
    key: Optional[StrictStr] = Field(default=None, description="The shared master key used to generate a TOTP token. Only used if generate is false.")
    key_size: Optional[StrictInt] = Field(default=20, description="Determines the size in bytes of the generated key. Only used if generate is true.")
    period: Optional[StrictStr] = Field(default='30', description="The length of time used to generate a counter for the TOTP token calculation.")
    qr_size: Optional[StrictInt] = Field(default=200, description="The pixel size of the generated square QR code. Only used if generate is true and exported is true. If this value is 0, a QR code will not be returned.")
    skew: Optional[StrictInt] = Field(default=1, description="The number of delay periods that are allowed when validating a TOTP token. This value can either be 0 or 1. Only used if generate is true.")
    url: Optional[StrictStr] = Field(default=None, description="A TOTP url string containing all of the parameters for key setup. Only used if generate is false.")
    __properties: ClassVar[List[str]] = ["account_name", "algorithm", "digits", "exported", "generate", "issuer", "key", "key_size", "period", "qr_size", "skew", "url"]

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

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

        _obj = cls.model_validate({
            "account_name": obj.get("account_name"),
            "algorithm": obj.get("algorithm") if obj.get("algorithm") is not None else 'SHA1',
            "digits": obj.get("digits") if obj.get("digits") is not None else 6,
            "exported": obj.get("exported") if obj.get("exported") is not None else True,
            "generate": obj.get("generate") if obj.get("generate") is not None else False,
            "issuer": obj.get("issuer"),
            "key": obj.get("key"),
            "key_size": obj.get("key_size") if obj.get("key_size") is not None else 20,
            "period": obj.get("period") if obj.get("period") is not None else '30',
            "qr_size": obj.get("qr_size") if obj.get("qr_size") is not None else 200,
            "skew": obj.get("skew") if obj.get("skew") is not None else 1,
            "url": obj.get("url")
        })
        return _obj


