# 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 PkiConfigureAutoTidyRequest(BaseModel):
    """
    PkiConfigureAutoTidyRequest
    """ # noqa: E501
    acme_account_safety_buffer: Optional[StrictStr] = Field(default='2592000', description="The amount of time that must pass after creation that an account with no orders is marked revoked, and the amount of time after being marked revoked or deactivated.")
    enabled: Optional[StrictBool] = Field(default=None, description="Set to true to enable automatic tidy operations.")
    interval_duration: Optional[StrictStr] = Field(default='43200', description="Interval at which to run an auto-tidy operation. This is the time between tidy invocations (after one finishes to the start of the next). Running a manual tidy will reset this duration.")
    issuer_safety_buffer: Optional[StrictStr] = Field(default='31536000', description="The amount of extra time that must have passed beyond issuer's expiration before it is removed from the backend storage. Defaults to 8760 hours (1 year).")
    maintain_stored_certificate_counts: Optional[StrictBool] = Field(default=False, description="This configures whether stored certificates are counted upon initialization of the backend, and whether during normal operation, a running count of certificates stored is maintained.")
    pause_duration: Optional[StrictStr] = Field(default='0s', description="The amount of time to wait between processing certificates. This allows operators to change the execution profile of tidy to take consume less resources by slowing down how long it takes to run. Note that the entire list of certificates will be stored in memory during the entire tidy operation, but resources to read/process/update existing entries will be spread out over a greater period of time. By default this is zero seconds.")
    publish_stored_certificate_count_metrics: Optional[StrictBool] = Field(default=False, description="This configures whether the stored certificate count is published to the metrics consumer. It does not affect if the stored certificate count is maintained, and if maintained, it will be available on the tidy-status endpoint.")
    revocation_queue_safety_buffer: Optional[StrictStr] = Field(default='172800', description="The amount of time that must pass from the cross-cluster revocation request being initiated to when it will be slated for removal. Setting this too low may remove valid revocation requests before the owning cluster has a chance to process them, especially if the cluster is offline.")
    safety_buffer: Optional[StrictStr] = Field(default='259200', description="The amount of extra time that must have passed beyond certificate expiration before it is removed from the backend storage and/or revocation list. Defaults to 72 hours.")
    tidy_acme: Optional[StrictBool] = Field(default=False, description="Set to true to enable tidying ACME accounts, orders and authorizations. ACME orders are tidied (deleted) safety_buffer after the certificate associated with them expires, or after the order and relevant authorizations have expired if no certificate was produced. Authorizations are tidied with the corresponding order. When a valid ACME Account is at least acme_account_safety_buffer old, and has no remaining orders associated with it, the account is marked as revoked. After another acme_account_safety_buffer has passed from the revocation or deactivation date, a revoked or deactivated ACME account is deleted.")
    tidy_cert_store: Optional[StrictBool] = Field(default=None, description="Set to true to enable tidying up the certificate store")
    tidy_cross_cluster_revoked_certs: Optional[StrictBool] = Field(default=None, description="Set to true to enable tidying up the cross-cluster revoked certificate store. Only runs on the active primary node.")
    tidy_expired_issuers: Optional[StrictBool] = Field(default=None, description="Set to true to automatically remove expired issuers past the issuer_safety_buffer. No keys will be removed as part of this operation.")
    tidy_move_legacy_ca_bundle: Optional[StrictBool] = Field(default=None, description="Set to true to move the legacy ca_bundle from /config/ca_bundle to /config/ca_bundle.bak. This prevents downgrades to pre-Vault 1.11 versions (as older PKI engines do not know about the new multi-issuer storage layout), but improves the performance on seal wrapped PKI mounts. This will only occur if at least issuer_safety_buffer time has occurred after the initial storage migration. This backup is saved in case of an issue in future migrations. Operators may consider removing it via sys/raw if they desire. The backup will be removed via a DELETE /root call, but note that this removes ALL issuers within the mount (and is thus not desirable in most operational scenarios).")
    tidy_revocation_list: Optional[StrictBool] = Field(default=None, description="Deprecated; synonym for 'tidy_revoked_certs")
    tidy_revocation_queue: Optional[StrictBool] = Field(default=False, description="Set to true to remove stale revocation queue entries that haven't been confirmed by any active cluster. Only runs on the active primary node")
    tidy_revoked_cert_issuer_associations: Optional[StrictBool] = Field(default=None, description="Set to true to validate issuer associations on revocation entries. This helps increase the performance of CRL building and OCSP responses.")
    tidy_revoked_certs: Optional[StrictBool] = Field(default=None, description="Set to true to expire all revoked and expired certificates, removing them both from the CRL and from storage. The CRL will be rotated if this causes any values to be removed.")
    __properties: ClassVar[List[str]] = ["acme_account_safety_buffer", "enabled", "interval_duration", "issuer_safety_buffer", "maintain_stored_certificate_counts", "pause_duration", "publish_stored_certificate_count_metrics", "revocation_queue_safety_buffer", "safety_buffer", "tidy_acme", "tidy_cert_store", "tidy_cross_cluster_revoked_certs", "tidy_expired_issuers", "tidy_move_legacy_ca_bundle", "tidy_revocation_list", "tidy_revocation_queue", "tidy_revoked_cert_issuer_associations", "tidy_revoked_certs"]

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

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

        _obj = cls.model_validate({
            "acme_account_safety_buffer": obj.get("acme_account_safety_buffer") if obj.get("acme_account_safety_buffer") is not None else '2592000',
            "enabled": obj.get("enabled"),
            "interval_duration": obj.get("interval_duration") if obj.get("interval_duration") is not None else '43200',
            "issuer_safety_buffer": obj.get("issuer_safety_buffer") if obj.get("issuer_safety_buffer") is not None else '31536000',
            "maintain_stored_certificate_counts": obj.get("maintain_stored_certificate_counts") if obj.get("maintain_stored_certificate_counts") is not None else False,
            "pause_duration": obj.get("pause_duration") if obj.get("pause_duration") is not None else '0s',
            "publish_stored_certificate_count_metrics": obj.get("publish_stored_certificate_count_metrics") if obj.get("publish_stored_certificate_count_metrics") is not None else False,
            "revocation_queue_safety_buffer": obj.get("revocation_queue_safety_buffer") if obj.get("revocation_queue_safety_buffer") is not None else '172800',
            "safety_buffer": obj.get("safety_buffer") if obj.get("safety_buffer") is not None else '259200',
            "tidy_acme": obj.get("tidy_acme") if obj.get("tidy_acme") is not None else False,
            "tidy_cert_store": obj.get("tidy_cert_store"),
            "tidy_cross_cluster_revoked_certs": obj.get("tidy_cross_cluster_revoked_certs"),
            "tidy_expired_issuers": obj.get("tidy_expired_issuers"),
            "tidy_move_legacy_ca_bundle": obj.get("tidy_move_legacy_ca_bundle"),
            "tidy_revocation_list": obj.get("tidy_revocation_list"),
            "tidy_revocation_queue": obj.get("tidy_revocation_queue") if obj.get("tidy_revocation_queue") is not None else False,
            "tidy_revoked_cert_issuer_associations": obj.get("tidy_revoked_cert_issuer_associations"),
            "tidy_revoked_certs": obj.get("tidy_revoked_certs")
        })
        return _obj


