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

class PkiWriteIssuerRequest(BaseModel):
    """
    PkiWriteIssuerRequest
    """ # noqa: E501
    crl_distribution_points: Optional[List[StrictStr]] = Field(default=None, description="Comma-separated list of URLs to be used for the CRL distribution points attribute. See also RFC 5280 Section 4.2.1.13.")
    enable_aia_url_templating: Optional[StrictBool] = Field(default=False, description="Whether or not to enabling templating of the above AIA fields. When templating is enabled the special values '{{issuer_id}}', '{{cluster_path}}', '{{cluster_aia_path}}' are available, but the addresses are not checked for URL validity until issuance time. Using '{{cluster_path}}' requires /config/cluster's 'path' member to be set on all PR Secondary clusters and using '{{cluster_aia_path}}' requires /config/cluster's 'aia_path' member to be set on all PR secondary clusters.")
    issuer_name: Optional[StrictStr] = Field(default=None, description="Provide a name to the generated or existing issuer, the name must be unique across all issuers and not be the reserved value 'default'")
    issuing_certificates: Optional[List[StrictStr]] = Field(default=None, description="Comma-separated list of URLs to be used for the issuing certificate attribute. See also RFC 5280 Section 4.2.2.1.")
    leaf_not_after_behavior: Optional[StrictStr] = Field(default='err', description="Behavior of leaf's NotAfter fields: \"err\" to error if the computed NotAfter date exceeds that of this issuer; \"truncate\" to silently truncate to that of this issuer; or \"permit\" to allow this issuance to succeed (with NotAfter exceeding that of an issuer). Note that not all values will results in certificates that can be validated through the entire validity period. It is suggested to use \"truncate\" for intermediate CAs and \"permit\" only for root CAs.")
    manual_chain: Optional[List[StrictStr]] = Field(default=None, description="Chain of issuer references to use to build this issuer's computed CAChain field, when non-empty.")
    ocsp_servers: Optional[List[StrictStr]] = Field(default=None, description="Comma-separated list of URLs to be used for the OCSP servers attribute. See also RFC 5280 Section 4.2.2.1.")
    revocation_signature_algorithm: Optional[StrictStr] = Field(default='', description="Which x509.SignatureAlgorithm name to use for signing CRLs. This parameter allows differentiation between PKCS#1v1.5 and PSS keys and choice of signature hash algorithm. The default (empty string) value is for Go to select the signature algorithm. This can fail if the underlying key does not support the requested signature algorithm, which may not be known at modification time (such as with PKCS#11 managed RSA keys).")
    usage: Optional[List[StrictStr]] = Field(default=None, description="Comma-separated list (or string slice) of usages for this issuer; valid values are \"read-only\", \"issuing-certificates\", \"crl-signing\", and \"ocsp-signing\". Multiple values may be specified. Read-only is implicit and always set.")
    __properties: ClassVar[List[str]] = ["crl_distribution_points", "enable_aia_url_templating", "issuer_name", "issuing_certificates", "leaf_not_after_behavior", "manual_chain", "ocsp_servers", "revocation_signature_algorithm", "usage"]

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

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

        _obj = cls.model_validate({
            "crl_distribution_points": obj.get("crl_distribution_points"),
            "enable_aia_url_templating": obj.get("enable_aia_url_templating") if obj.get("enable_aia_url_templating") is not None else False,
            "issuer_name": obj.get("issuer_name"),
            "issuing_certificates": obj.get("issuing_certificates"),
            "leaf_not_after_behavior": obj.get("leaf_not_after_behavior") if obj.get("leaf_not_after_behavior") is not None else 'err',
            "manual_chain": obj.get("manual_chain"),
            "ocsp_servers": obj.get("ocsp_servers"),
            "revocation_signature_algorithm": obj.get("revocation_signature_algorithm") if obj.get("revocation_signature_algorithm") is not None else '',
            "usage": obj.get("usage")
        })
        return _obj


