# coding: utf-8

"""
    Rancher Solution API

    Simplify enterprise-grade Kubernetes cluster operations and management with Rancher on Bare Metal Cloud. Deploy Kubernetes clusters using a few API calls.<br> <br> <span class='pnap-api-knowledge-base-link'> Knowledge base articles to help you can be found <a href='https://phoenixnap.com/kb/rancher-bmc-integration-kubernetes' target='_blank'>here</a> </span><br> <br> <b>All URLs are relative to (https://api.phoenixnap.com/solutions/rancher/v1beta)</b> 

    The version of the OpenAPI document: 0.1
    Contact: support@phoenixnap.com
    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 typing import Any, ClassVar, Dict, List, Optional
from pydantic import BaseModel, StrictInt, StrictStr
from pydantic import Field
from pnap_rancher_solution_api.models.rancher_cluster_certificates import RancherClusterCertificates
try:
    from typing import Self
except ImportError:
    from typing_extensions import Self

class RancherClusterConfig(BaseModel):
    """
    (Write-only) Rancher configuration parameters.
    """ # noqa: E501
    token: Optional[StrictStr] = Field(default=None, description="Shared secret used to join a server or agent to a cluster.")
    tls_san: Optional[StrictStr] = Field(default=None, description="This maps to ranchers `tls-san`. Add additional hostname or IP as a Subject Alternative Name in the TLS cert.", alias="tlsSan")
    etcd_snapshot_schedule_cron: Optional[StrictStr] = Field(default='0 0,12 * * *', description="This maps to ranchers `etcd-snapshot-schedule-cron`. Snapshot interval time in cron spec. eg. every 5 hours ‘0 */5 * * *’. Default: at 12 am/pm", alias="etcdSnapshotScheduleCron")
    etcd_snapshot_retention: Optional[StrictInt] = Field(default=5, description="This maps to ranchers `etcd-snapshot-retention`. Number of snapshots to retain.", alias="etcdSnapshotRetention")
    node_taint: Optional[StrictStr] = Field(default=None, description="This maps to ranchers `node-taint`. Registering kubelet with set of taints. By default, server nodes will be schedulable and thus your workloads can get launched on them. If you wish to have a dedicated control plane where no user workloads will run, you can use taints.", alias="nodeTaint")
    cluster_domain: Optional[StrictStr] = Field(default=None, description="This maps to ranchers `cluster-domain`. Cluster Domain.", alias="clusterDomain")
    certificates: Optional[RancherClusterCertificates] = None
    additional_properties: Dict[str, Any] = {}
    __properties: ClassVar[List[str]] = ["token", "tlsSan", "etcdSnapshotScheduleCron", "etcdSnapshotRetention", "nodeTaint", "clusterDomain", "certificates"]

    model_config = {
        "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) -> Self:
        """Create an instance of RancherClusterConfig 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.
        * Fields in `self.additional_properties` are added to the output dict.
        """
        _dict = self.model_dump(
            by_alias=True,
            exclude={
                "additional_properties",
            },
            exclude_none=True,
        )
        # override the default output from pydantic by calling `to_dict()` of certificates
        if self.certificates:
            _dict['certificates'] = self.certificates.to_dict()
        # puts key-value pairs in additional_properties in the top level
        if self.additional_properties is not None:
            for _key, _value in self.additional_properties.items():
                _dict[_key] = _value

        return _dict

    @classmethod
    def from_dict(cls, obj: Dict) -> Self:
        """Create an instance of RancherClusterConfig from a dict"""
        if obj is None:
            return None

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

        _obj = cls.model_validate({
            "token": obj.get("token"),
            "tlsSan": obj.get("tlsSan"),
            "etcdSnapshotScheduleCron": obj.get("etcdSnapshotScheduleCron") if obj.get("etcdSnapshotScheduleCron") is not None else '0 0,12 * * *',
            "etcdSnapshotRetention": obj.get("etcdSnapshotRetention") if obj.get("etcdSnapshotRetention") is not None else 5,
            "nodeTaint": obj.get("nodeTaint"),
            "clusterDomain": obj.get("clusterDomain"),
            "certificates": RancherClusterCertificates.from_dict(obj.get("certificates")) if obj.get("certificates") is not None else None
        })
        # store additional fields in additional_properties
        for _key in obj.keys():
            if _key not in cls.__properties:
                _obj.additional_properties[_key] = obj.get(_key)

        return _obj


