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

class KubernetesWriteRoleRequest(BaseModel):
    """
    KubernetesWriteRoleRequest
    """ # noqa: E501
    allowed_kubernetes_namespace_selector: Optional[StrictStr] = Field(default=None, description="A label selector for Kubernetes namespaces in which credentials can be generated. Accepts either a JSON or YAML object. If set with allowed_kubernetes_namespaces, the conditions are conjuncted.")
    allowed_kubernetes_namespaces: Optional[List[StrictStr]] = Field(default=None, description="A list of the Kubernetes namespaces in which credentials can be generated. If set to \"*\" all namespaces are allowed.")
    extra_annotations: Optional[Dict[str, Any]] = Field(default=None, description="Additional annotations to apply to all generated Kubernetes objects.")
    extra_labels: Optional[Dict[str, Any]] = Field(default=None, description="Additional labels to apply to all generated Kubernetes objects.")
    generated_role_rules: Optional[StrictStr] = Field(default=None, description="The Role or ClusterRole rules to use when generating a role. Accepts either a JSON or YAML object. If set, the entire chain of Kubernetes objects will be generated.")
    kubernetes_role_name: Optional[StrictStr] = Field(default=None, description="The pre-existing Role or ClusterRole to bind a generated service account to. If set, Kubernetes token, service account, and role binding objects will be created.")
    kubernetes_role_type: Optional[StrictStr] = Field(default='Role', description="Specifies whether the Kubernetes role is a Role or ClusterRole.")
    name_template: Optional[StrictStr] = Field(default=None, description="The name template to use when generating service accounts, roles and role bindings. If unset, a default template is used.")
    service_account_name: Optional[StrictStr] = Field(default=None, description="The pre-existing service account to generate tokens for. Mutually exclusive with all role parameters. If set, only a Kubernetes service account token will be created.")
    token_default_audiences: Optional[List[StrictStr]] = Field(default=None, description="The default audiences for generated Kubernetes service account tokens. If not set or set to \"\", will use k8s cluster default.")
    token_default_ttl: Optional[StrictStr] = Field(default=None, description="The default ttl for generated Kubernetes service account tokens. If not set or set to 0, will use system default.")
    token_max_ttl: Optional[StrictStr] = Field(default=None, description="The maximum ttl for generated Kubernetes service account tokens. If not set or set to 0, will use system default.")
    __properties: ClassVar[List[str]] = ["allowed_kubernetes_namespace_selector", "allowed_kubernetes_namespaces", "extra_annotations", "extra_labels", "generated_role_rules", "kubernetes_role_name", "kubernetes_role_type", "name_template", "service_account_name", "token_default_audiences", "token_default_ttl", "token_max_ttl"]

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

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

        _obj = cls.model_validate({
            "allowed_kubernetes_namespace_selector": obj.get("allowed_kubernetes_namespace_selector"),
            "allowed_kubernetes_namespaces": obj.get("allowed_kubernetes_namespaces"),
            "extra_annotations": obj.get("extra_annotations"),
            "extra_labels": obj.get("extra_labels"),
            "generated_role_rules": obj.get("generated_role_rules"),
            "kubernetes_role_name": obj.get("kubernetes_role_name"),
            "kubernetes_role_type": obj.get("kubernetes_role_type") if obj.get("kubernetes_role_type") is not None else 'Role',
            "name_template": obj.get("name_template"),
            "service_account_name": obj.get("service_account_name"),
            "token_default_audiences": obj.get("token_default_audiences"),
            "token_default_ttl": obj.get("token_default_ttl"),
            "token_max_ttl": obj.get("token_max_ttl")
        })
        return _obj


